mirror of
https://example.com
synced 2024-11-22 22:06:40 +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
|
#!/usr/bin/env bash
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
|
function color {
|
||||||
|
if [[ -t 1 ]]; then
|
||||||
|
tput setaf ${1:-7}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function say {
|
function say {
|
||||||
tput setaf 5
|
color 5 # magenta
|
||||||
echo -e "( ^-^) < $1"
|
echo -e "( ^-^) < $1"
|
||||||
tput setaf 7
|
color
|
||||||
}
|
}
|
||||||
|
|
||||||
function running {
|
function running {
|
||||||
tput setaf 3
|
color 3 # yellow
|
||||||
echo "[running] \$ $1"
|
echo "[running] \$ $1"
|
||||||
tput setaf 7
|
color
|
||||||
}
|
}
|
||||||
|
|
||||||
say "Start upgrading Firefish!"
|
say "Start upgrading Firefish!"
|
||||||
|
|
Loading…
Reference in a new issue