]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
tests: shell: Print escape sequences with terminals only
authorPhil Sutter <phil@nwl.cc>
Wed, 6 Nov 2024 12:57:30 +0000 (13:57 +0100)
committerPhil Sutter <phil@nwl.cc>
Wed, 6 Nov 2024 15:09:52 +0000 (16:09 +0100)
If stdout is not a terminal, don't print the '[EXECUTING]' status line
which has to be cleared again.

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

index 2ad259c21644ce525fa74e7627c2bd9ec5760cce..565b654e9f1347e7b12d4da1f9b3dcb8a2d0ed8c 100755 (executable)
@@ -165,7 +165,7 @@ do_test() {
 
        rc_spec=`echo $(basename ${testfile}) | cut -d _ -f2-`
 
-       msg_info "[EXECUTING]   $testfile"
+       [ -t 1 ] && msg_info "[EXECUTING]   $testfile"
 
        if [ "$VERBOSE" = "y" ]; then
                XT_MULTI=$xtables_multi unshare -n ${testfile}
@@ -173,7 +173,7 @@ do_test() {
        else
                XT_MULTI=$xtables_multi unshare -n ${testfile} > /dev/null 2>&1
                rc_got=$?
-               echo -en "\033[1A\033[K" # clean the [EXECUTING] foobar line
+               [ -t 1 ] && echo -en "\033[1A\033[K" # clean the [EXECUTING] foobar line
        fi
 
        if [ "$rc_got" == "$rc_spec" ] ; then