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:
parent
d0d5f42484
commit
534d3511f7
1 changed files with 10 additions and 4 deletions
14
update.sh
14
update.sh
|
@ -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!"
|
||||
|
|
Loading…
Reference in a new issue