detect terminal output with 'test -t' in tests
authorDavid Kalnischkies <david@kalnischkies.de>
Sun, 7 Sep 2014 17:30:33 +0000 (19:30 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Sun, 7 Sep 2014 17:30:33 +0000 (19:30 +0200)
Instead of trying to inspect /proc and the fds inside we use "test -t 1"
instead as this is available and working on kfreebsd as well – not that
something breaks if we wouldn't, but we like color.

Git-Dch: Ignore

test/integration/framework
test/integration/run-tests

index fde74f5..ff010a5 100644 (file)
@@ -4,7 +4,7 @@ EXIT_CODE=0
 
 # we all like colorful messages
 if [ "$MSGCOLOR" != 'NO' ]; then
-       if ! expr match "$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev/null; then
+       if [ ! -t 1 ]; then # but check that we output to a terminal
                export MSGCOLOR='NO'
        fi
 fi
index 9dd550a..c39a2ac 100755 (executable)
@@ -22,7 +22,7 @@ done
 export MSGLEVEL="${MSGLEVEL:-3}"
 
 if [ "$MSGCOLOR" != 'NO' ]; then
-       if ! expr match "$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev/null; then
+       if [ ! -t 1 ]; then # but check that we output to a terminal
                export MSGCOLOR='NO'
        fi
 fi