diff options
| author | Tomi Ollila <tomi.ollila@iki.fi> | 2019-05-08 21:51:47 +0300 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2019-05-23 08:00:31 -0300 |
| commit | 3563079be37737aab084e957b494070eaea9c2f6 (patch) | |
| tree | 4db999c1b507e7676034f003af9fab056fc24b27 /test/test-lib.sh | |
| parent | a1aea7272e3dd98c389402791617a00b92783f86 (diff) | |
test-lib.sh: colors to test output when parallel(1) is run on tty
Done via $COLORS_WITHOUT_TTY environment variable as passing options
to commands through parallel(1) does not look trivial.
Reorganized color checking in test-lib.sh a bit for this (perhaps
were not fully necessary but rest still an improvement):
- color checking commands in subshell are not run before arg parsing
(args may disable colors with --no-color)
- [ -t 1 ] is checked before forking subshell
Diffstat (limited to 'test/test-lib.sh')
| -rw-r--r-- | test/test-lib.sh | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/test/test-lib.sh b/test/test-lib.sh index 068e1029..ff18fae6 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -134,15 +134,7 @@ add_gnupg_home () # ' # . ./test-lib.sh || exit 1 -[ "x$ORIGINAL_TERM" != "xdumb" ] && ( - TERM=$ORIGINAL_TERM && - export TERM && - [ -t 1 ] && - tput bold >/dev/null 2>&1 && - tput setaf 1 >/dev/null 2>&1 && - tput sgr0 >/dev/null 2>&1 - ) && - color=t +color=maybe while test "$#" -ne 0 do @@ -183,6 +175,21 @@ else } fi +test -n "$COLORS_WITHOUT_TTY" || [ -t 1 ] || color= + +if [ -n "$color" ] && [ "$ORIGINAL_TERM" != 'dumb' ] && ( + TERM=$ORIGINAL_TERM && + export TERM && + tput bold + tput setaf + tput sgr0 + ) >/dev/null 2>&1 +then + color=t +else + color= +fi + if test -n "$color"; then say_color () { ( |
