fixeria submitted this change.

View Change

Approvals: fixeria: Looks good to me, approved pespin: Looks good to me, but someone else must approve msuraev: Looks good to me, but someone else must approve arehbein: Looks good to me, but someone else must approve Jenkins Builder: Verified
fixup: ttcn3-tcpdump*.sh: Fix output of special chars

On ArchLinux /bin/sh is actually a symlink to bash, so bash is running
in limited mode and emulating the Bourne Shell. The shell detection
logic added in [1] does not work correctly for me because the cmdline
would be 'sh' or '/bin/sh', not 'bash'. This is what I am getting:

\033[1;32m====== FooBar_Tests.TC_foo_bar pass ======\033[0m

Let's switch to printf, which does interpret the backslash escapes
as expected by default, regardless of the actual shell in use.

Also fix ttcn3-dumpcap-stop.sh, which was left untouched by [1].

Change-Id: Id28193a7ca00b5501a6852e5b4a5412fbaa5e063
Fixes: [1] bf45a5cff890a6103c68d76c1cf088c26ca9aa80
---
M ttcn3-dumpcap-stop.sh
M ttcn3-tcpdump-stop.sh
2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/ttcn3-dumpcap-stop.sh b/ttcn3-dumpcap-stop.sh
index e13fbc0..188b8da 100755
--- a/ttcn3-dumpcap-stop.sh
+++ b/ttcn3-dumpcap-stop.sh
@@ -22,11 +22,10 @@
date

if [ x"$VERDICT" = x"pass" ]; then
- echo -e "\033[1;32m====== $TESTCASE $VERDICT ======\033[0m"
+ printf "\033[1;32m====== $TESTCASE $VERDICT ======\033[0m\n\n"
else
- echo -e "\033[1;31m------ $TESTCASE $VERDICT ------\033[0m"
+ printf "\033[1;31m------ $TESTCASE $VERDICT ------\033[0m\n\n"
fi
-echo

if [ "z$TTCN3_PCAP_PATH" = "z" ]; then
TTCN3_PCAP_PATH=/tmp
diff --git a/ttcn3-tcpdump-stop.sh b/ttcn3-tcpdump-stop.sh
index 0feaeaa..82d3a4f 100755
--- a/ttcn3-tcpdump-stop.sh
+++ b/ttcn3-tcpdump-stop.sh
@@ -26,21 +26,11 @@

date

-# -e only works/is required only in Bash; in dash/POSIX shells it isn't required and will be part of the output
-# SHELL environment variable doesn't always give name of current shell (e.g. for dash run inside bash...)
-SHELL_NAME="$(cat /proc/$$/cmdline | tr -d '\0')"
-if [ "$SHELL_NAME" = "bash" ]; then
- ESCAPE_OPT="-e"
-else
- ESCAPE_OPT=""
-fi
-
if [ x"$VERDICT" = x"pass" ]; then
- echo $ESCAPE_OPT "\033[1;32m====== $TESTCASE $VERDICT ======\033[0m"
+ printf "\033[1;32m====== $TESTCASE $VERDICT ======\033[0m\n\n"
else
- echo $ESCAPE_OPT "\033[1;31m------ $TESTCASE $VERDICT ------\033[0m"
+ printf "\033[1;31m------ $TESTCASE $VERDICT ------\033[0m\n\n"
fi
-echo

if [ "z$TTCN3_PCAP_PATH" = "z" ]; then
TTCN3_PCAP_PATH=/tmp

To view, visit change 30682. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Id28193a7ca00b5501a6852e5b4a5412fbaa5e063
Gerrit-Change-Number: 30682
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: arehbein <arehbein@sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: msuraev <msuraev@sysmocom.de>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>
Gerrit-MessageType: merged