From ae6a6bff81f9cfa08ce246b9976ba7ff963af6dd Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Thu, 10 Jul 2025 10:02:17 +0200 Subject: [PATCH] Update core.func --- misc/core.func | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/misc/core.func b/misc/core.func index a8774fc2..b4293ca6 100644 --- a/misc/core.func +++ b/misc/core.func @@ -327,6 +327,10 @@ fatal() { kill -INT $$ } +# ------------------------------------------------------------------------------ +# Spinner- und Messaging-Framework (TTY-sicher, CI-kompatibel) +# ------------------------------------------------------------------------------ + spinner() { local chars=(⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏) local i=0 @@ -337,11 +341,6 @@ spinner() { done } -clear_line() { - tput cr 2>/dev/null || echo -en "\r" - tput el 2>/dev/null || echo -en "\033[K" -} - stop_spinner() { local pid="${SPINNER_PID:-}" [[ -z "$pid" && -f /tmp/.spinner.pid ]] && pid=$(&2 + printf "\r\e[2K%s %b\n" "$HOURGLASS" "${YW}${msg}${CL}" >&2 return fi - color_spinner - spinner & - SPINNER_PID=$! - echo "$SPINNER_PID" >/tmp/.spinner.pid - disown "$SPINNER_PID" 2>/dev/null || true + # Spinner nur starten, wenn ein echtes TTY und keine SIGTTOU-Gefahr + if [[ -t 1 && ! "$(ps -o stat= -p $$)" =~ T && -z "$NO_SPINNER" ]]; then + color_spinner + spinner & + SPINNER_PID=$! + echo "$SPINNER_PID" >/tmp/.spinner.pid + disown "$SPINNER_PID" 2>/dev/null || true + else + # Fallback: reiner Text + printf "\r\e[2K⏳ %b\n" "${YW}${msg}${CL}" >&2 + fi } msg_ok() { @@ -415,6 +421,11 @@ msg_custom() { echo -e "${BFR:-} ${symbol} ${color}${msg}${CL:-\e[0m}" } +clear_line() { + tput cr 2>/dev/null || echo -en "\r" + tput el 2>/dev/null || echo -en "\033[K" +} + # msg_ok() { # local msg="$1" # [[ -z "$msg" ]] && return