]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: shell: Avoid escape chars when printing to non-terminals
authorPhil Sutter <phil@nwl.cc>
Sat, 23 Mar 2024 02:09:41 +0000 (03:09 +0100)
committerPhil Sutter <phil@nwl.cc>
Fri, 12 Apr 2024 12:41:34 +0000 (14:41 +0200)
Print the 'EXECUTING' status line only if stdout is a terminal, the
mandatory following escape sequence to delete it messes up log file
contents.

Signed-off-by: Phil Sutter <phil@nwl.cc>
tests/shell/run-tests.sh

index 86c8312683ccb389bb9e3383808ce91133d3ebdd..6a9b518c3aed5114edefb0e624a9dbf0574a9deb 100755 (executable)
@@ -860,7 +860,7 @@ job_start() {
        local testfile="$1"
        local testidx="$2"
 
-       if [ "$NFT_TEST_JOBS" -le 1 ] ; then
+       if [ "$NFT_TEST_JOBS" -le 1 ] && [[ -t 1 ]]; then
                print_test_header I "$testfile" "$testidx" "EXECUTING"
        fi
 
@@ -873,7 +873,7 @@ job_start() {
        $NFT_TEST_UNSHARE_CMD "$NFT_TEST_BASEDIR/helpers/test-wrapper.sh" "$testfile"
        local rc_got=$?
 
-       if [ "$NFT_TEST_JOBS" -le 1 ] ; then
+       if [ "$NFT_TEST_JOBS" -le 1 ] && [[ -t 1 ]]; then
                echo -en "\033[1A\033[K" # clean the [EXECUTING] foobar line
        fi