Update core.func
This commit is contained in:
parent
6eb096f8af
commit
b15861d84f
@ -439,23 +439,28 @@ fatal() {
|
|||||||
|
|
||||||
spinner() {
|
spinner() {
|
||||||
local chars="⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏" i=0
|
local chars="⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏" i=0
|
||||||
printf "\e[?25l"
|
printf "\e[?25l" # hide cursor
|
||||||
while true; do
|
while :; do
|
||||||
printf "\r \e[36m%s\e[0m" "${chars:i++%${#chars}:1}"
|
printf "\r \e[36m%s\e[0m" "${chars:i++%${#chars}:1}"
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_spinner() {
|
stop_spinner() {
|
||||||
local pid="${SPINNER_PID:-}"
|
local pid
|
||||||
|
|
||||||
|
# Get PID from variable or temp file
|
||||||
|
pid="${SPINNER_PID:-}"
|
||||||
[[ -z "$pid" && -f /tmp/spinner.pid ]] && pid=$(</tmp/spinner.pid)
|
[[ -z "$pid" && -f /tmp/spinner.pid ]] && pid=$(</tmp/spinner.pid)
|
||||||
|
|
||||||
if [[ -n "$pid" && "$pid" =~ ^[0-9]+$ ]]; then
|
if [[ -n "$pid" && "$pid" =~ ^[0-9]+$ ]]; then
|
||||||
kill "$pid" 2>/dev/null
|
if kill "$pid" 2>/dev/null; then
|
||||||
wait "$pid" 2>/dev/null || true
|
wait "$pid" 2>/dev/null || true
|
||||||
|
fi
|
||||||
rm -f /tmp/spinner.pid
|
rm -f /tmp/spinner.pid
|
||||||
SPINNER_PID=""
|
unset SPINNER_PID
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "\r\033[K\e[?25h" # clear line + show cursor
|
printf "\r\033[K\e[?25h" # clear line + show cursor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user