From bf45a5cff890a6103c68d76c1cf088c26ca9aa80 Mon Sep 17 00:00:00 2001 From: arehbein Date: Sun, 13 Nov 2022 18:48:58 +0100 Subject: [PATCH] ttcn3-tcpdump*.sh: Fix output of special chars Don't print '-e' option in non-bash shells. Related: OS#5736 Change-Id: Idac0f902d2f5eb142a3f130409451c8f77b111f6 --- ttcn3-tcpdump-stop.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ttcn3-tcpdump-stop.sh b/ttcn3-tcpdump-stop.sh index 829ed2b20..056805419 100755 --- a/ttcn3-tcpdump-stop.sh +++ b/ttcn3-tcpdump-stop.sh @@ -24,10 +24,17 @@ kill_rm_pidfile() { date -if [ x"$VERDICT" = x"pass" ]; then - echo -e "\033[1;32m====== $TESTCASE $VERDICT ======\033[0m" +# -e only works/is required only in Bash; in dash/POSIX shells it isn't required and will be part of the output +if (lsof -p $$ | grep -q /usr/bin/bash); then + ESCAPE_OPT="-e" else - echo -e "\033[1;31m------ $TESTCASE $VERDICT ------\033[0m" + ESCAPE_OPT="" +fi + +if [ x"$VERDICT" = x"pass" ]; then + echo $ESCAPE_OPT "\033[1;32m====== $TESTCASE $VERDICT ======\033[0m" +else + echo $ESCAPE_OPT "\033[1;31m------ $TESTCASE $VERDICT ------\033[0m" fi echo