Update core.func

This commit is contained in:
CanbiZ 2025-05-15 11:41:49 +02:00
parent ecd561f525
commit d8a5421a11

View File

@ -239,7 +239,7 @@ start_spinner() {
SPINNER_MSG="$msg" SPINNER_MSG="$msg"
SPINNER_ACTIVE=1 SPINNER_ACTIVE=1
_spinner_loop() { {
while [[ "$SPINNER_ACTIVE" -eq 1 ]]; do while [[ "$SPINNER_ACTIVE" -eq 1 ]]; do
if [[ -t 2 ]]; then if [[ -t 2 ]]; then
printf "\r\e[2K%s %b" "${TAB}${spinner_frames[spin_i]}${TAB}" "${YW}${SPINNER_MSG}${CL}" >&2 printf "\r\e[2K%s %b" "${TAB}${spinner_frames[spin_i]}${TAB}" "${YW}${SPINNER_MSG}${CL}" >&2
@ -250,10 +250,15 @@ start_spinner() {
spin_i=$(((spin_i + 1) % ${#spinner_frames[@]})) spin_i=$(((spin_i + 1) % ${#spinner_frames[@]}))
sleep "$interval" sleep "$interval"
done done
} } &
_spinner_loop & local pid=$!
SPINNER_PID=$! if ps -p "$pid" >/dev/null 2>&1; then
SPINNER_PID="$pid"
else
SPINNER_ACTIVE=0
SPINNER_PID=""
fi
} }
# === Spinner Stop === # === Spinner Stop ===
@ -269,8 +274,8 @@ stop_spinner() {
done done
fi fi
if [[ "$SPINNER_PID" =~ ^[0-9]+$ ]] && ps -p "$SPINNER_PID" -o pid= >/dev/null 2>&1; then if [[ "$SPINNER_PID" =~ ^[0-9]+$ ]]; then
wait "$SPINNER_PID" 2>/dev/null || true ps -p "$SPINNER_PID" -o pid= >/dev/null 2>&1 && wait "$SPINNER_PID" 2>/dev/null || true
fi fi
printf "\r\e[2K" >&2 printf "\r\e[2K" >&2