1
0
Fork 1
mirror of https://example.com synced 2024-11-22 16:26:38 +09:00

dev: don't print ANSI escape chars if stdout is piped/redirected

This commit is contained in:
naskya 2023-10-27 23:39:24 +09:00
parent d0d5f42484
commit 534d3511f7
Signed by: naskya
GPG key ID: 164DFF24E2D40139

View file

@ -1,16 +1,22 @@
#!/usr/bin/env bash
set -eu
function color {
if [[ -t 1 ]]; then
tput setaf ${1:-7}
fi
}
function say {
tput setaf 5
color 5 # magenta
echo -e "( ^-^) < $1"
tput setaf 7
color
}
function running {
tput setaf 3
color 3 # yellow
echo "[running] \$ $1"
tput setaf 7
color
}
say "Start upgrading Firefish!"