Compare commits

..

No commits in common. "d76362808662b229ab5d9958ed9deb0f3be53274" and "8e10c14bce6f7c8f32d85fb87e9480de5160fe41" have entirely different histories.

4 changed files with 11 additions and 89 deletions

View File

@ -25,8 +25,6 @@ trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
# This function handles errors
function error_handler() {
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
printf "\e[?25h"
local exit_code="$?"
local line_number="$1"
local command="$2"
@ -34,37 +32,20 @@ function error_handler() {
echo -e "\n$error_message\n"
}
# This function displays a spinner.
function spinner() {
printf "\e[?25l"
spinner="/-\\|/-\\|"
spin_i=0
while true; do
printf "\b%s" "${spinner:spin_i++%${#spinner}:1}"
sleep 0.1
done
}
# This function displays an informational message with a yellow color.
# This function prints an informational message
function msg_info() {
local msg="$1"
echo -ne " ${HOLD} ${YW}${msg} "
spinner &
SPINNER_PID=$!
echo -ne " ${HOLD} ${YW}${msg}..."
}
# This function displays a success message with a green color.
# This function prints a success message
function msg_ok() {
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
printf "\e[?25h"
local msg="$1"
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
}
# This function displays a error message with a red color.
# This function prints an error message
function msg_error() {
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
printf "\e[?25h"
local msg="$1"
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
}

View File

@ -27,8 +27,6 @@ catch_errors() {
# This function is called when an error occurs. It receives the exit code, line number, and command that caused the error, and displays an error message.
error_handler() {
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
printf "\e[?25h"
local exit_code="$?"
local line_number="$1"
local command="$2"
@ -36,38 +34,20 @@ error_handler() {
echo -e "\n$error_message\n"
}
# This function displays a spinner.
spinner() {
printf "\e[?25l"
spinner="/-\\|/-\\|"
spin_i=0
while true; do
printf "\b%s" "${spinner:spin_i++%${#spinner}:1}"
sleep 0.1
done
}
# This function displays an informational message with a yellow color.
msg_info() {
local msg="$1"
echo -ne " ${HOLD} ${YW}${msg} "
spinner &
SPINNER_PID=$!
echo -ne " ${HOLD} ${YW}${msg}..."
}
# This function displays a success message with a green color.
msg_ok() {
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
printf "\e[?25h"
local msg="$1"
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
}
# This function displays a error message with a red color.
# This function displays an error message with a red color.
msg_error() {
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
printf "\e[?25h"
local msg="$1"
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
}

View File

@ -36,8 +36,6 @@ catch_errors() {
# This function handles errors
error_handler() {
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
printf "\e[?25h"
local exit_code="$?"
local line_number="$1"
local command="$2"
@ -48,38 +46,20 @@ error_handler() {
fi
}
# This function displays a spinner.
spinner() {
printf "\e[?25l"
spinner="/-\\|/-\\|"
spin_i=0
while true; do
printf "\b%s" "${spinner:spin_i++%${#spinner}:1}"
sleep 0.1
done
}
# This function displays an informational message with a yellow color.
# This function prints an informational message
msg_info() {
local msg="$1"
echo -ne " ${HOLD} ${YW}${msg} "
spinner &
SPINNER_PID=$!
echo -ne " ${HOLD} ${YW}${msg}..."
}
# This function displays a success message with a green color.
# This function prints a success message
msg_ok() {
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
printf "\e[?25h"
local msg="$1"
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
}
# This function displays a error message with a red color.
# This function prints an error message
msg_error() {
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
printf "\e[?25h"
local msg="$1"
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
}

View File

@ -40,10 +40,7 @@ THIN="discard=on,ssd=1,"
set -Eeuo pipefail
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
trap cleanup EXIT
function error_handler() {
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
printf "\e[?25h"
local exit_code="$?"
local line_number="$1"
local command="$2"
@ -72,33 +69,17 @@ else
header_info && echo -e "⚠ User exited script \n" && exit
fi
function spinner() {
printf "\e[?25l"
spinner="/-\\|/-\\|"
spin_i=0
while true; do
printf "\b%s" "${spinner:spin_i++%${#spinner}:1}"
sleep 0.1
done
}
function msg_info() {
local msg="$1"
echo -ne " ${HOLD} ${YW}${msg} "
spinner &
SPINNER_PID=$!
echo -ne " ${HOLD} ${YW}${msg}..."
}
function msg_ok() {
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
printf "\e[?25h"
local msg="$1"
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
}
function msg_error() {
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
printf "\e[?25h"
local msg="$1"
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
}