fix: suppress ANSI colors when stdout is not a terminal

Color variables set to empty strings when stdout is not a tty, preventing
escape codes from being interpreted as commands by background task runners
This commit is contained in:
pyr0ball 2026-05-09 10:16:03 -07:00
parent 040428c513
commit 27e33ae85e

View file

@ -3,7 +3,12 @@
# Usage: ./manage.sh <command> [args] # Usage: ./manage.sh <command> [args]
set -euo pipefail set -euo pipefail
# Only emit color codes when stdout is a real terminal
if [[ -t 1 ]]; then
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m' RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m'
else
RED=''; GREEN=''; YELLOW=''; BLUE=''; NC=''
fi
info() { echo -e "${BLUE}[turnstone]${NC} $*"; } info() { echo -e "${BLUE}[turnstone]${NC} $*"; }
success() { echo -e "${GREEN}[turnstone]${NC} $*"; } success() { echo -e "${GREEN}[turnstone]${NC} $*"; }
warn() { echo -e "${YELLOW}[turnstone]${NC} $*"; } warn() { echo -e "${YELLOW}[turnstone]${NC} $*"; }