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:
parent
040428c513
commit
27e33ae85e
1 changed files with 6 additions and 1 deletions
|
|
@ -3,7 +3,12 @@
|
||||||
# Usage: ./manage.sh <command> [args]
|
# Usage: ./manage.sh <command> [args]
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m'
|
# 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'
|
||||||
|
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} $*"; }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue