Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1753?usp=email
to review the following change.
Change subject: t_client.sh.in: Improve output when echo -e writes "echo -e"
......................................................................
t_client.sh.in: Improve output when echo -e writes "echo -e"
In some shells the echo builtin doesn't interpret -e as
an argument, it just outputs it as a string. These shells
generally still behave like -e was given, so check whether
we need to specify it. Makes the output a bit nicer in those
shells.
Examples for shells I have observed this with are dash on
Ubuntu and /bin/sh on macOS.
Change-Id: I746bd8c0fa3496d23569cde496438fc4189600fe
Signed-off-by: Frank Lichtenheld <[email protected]>
---
M tests/t_client.sh.in
1 file changed, 21 insertions(+), 9 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/53/1753/1
diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in
index 48e2446..c92fb4a 100755
--- a/tests/t_client.sh.in
+++ b/tests/t_client.sh.in
@@ -62,6 +62,18 @@
exit 1
fi
+echoout=`echo -e "foo\cbar"`
+if [ "$echoout" = "foo" ]; then
+ ECHO_E="-e"
+elif [ "$echoout" = "-e foo" ]; then
+ # echo doesn't interpret -e but supports escape sequences
+ # e.g. dash echo builtin
+ ECHO_E=
+else
+ echo "something is wrong with your 'echo' command. FAIL." >&2
+ exit 1
+fi
+
if [ -z "$TEST_RUN_LIST" ] ; then
echo "TEST_RUN_LIST empty, no tests defined. SKIP test." >&2
exit "${TCLIENT_SKIP_RC}"
@@ -132,9 +144,9 @@
{
case $V in
0) outbuf="" ;; # no per-test output at all
- 1) echo -e "$@" # compact, details only on failure
+ 1) echo $ECHO_E "$@" # compact, details only on
failure
outbuf="\n" ;;
- *) echo -e "\n$@\n" ;; # print all, with a bit formatting
+ *) echo $ECHO_E "\n$@\n" ;; # print all, with a bit
formatting
esac
}
@@ -146,7 +158,7 @@
1) outbuf="$outbuf$@" # print details only on failure
test -z "$NO_NL" && outbuf="$outbuf\n"
;;
- *) echo -e $NO_NL "$@" ;; # print everything
+ *) echo $ECHO_E $NO_NL "$@" ;; # print everything
esac
}
@@ -340,7 +352,7 @@
else
output "skip check failed, SKIP test $SUF."
SUMMARY_SKIP="$SUMMARY_SKIP $SUF"
- echo -e "$outbuf" ; continue
+ echo $ECHO_E "$outbuf" ; continue
fi
fi
@@ -361,7 +373,7 @@
fail "make sure that ping hosts are ONLY reachable via VPN, SKIP test
$SUF."
SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
exit_code=31
- echo -e "$outbuf" ; continue
+ echo $ECHO_E "$outbuf" ; continue
fi
pidfile="${top_builddir}/tests/$LOGDIR/openvpn-$SUF.pid"
@@ -407,7 +419,7 @@
trap - 0 1 2 3 15
SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
exit_code=30
- echo -e "$outbuf" ; continue
+ echo $ECHO_E "$outbuf" ; continue
fi
# make sure openvpn client is terminated in case shell exits
@@ -470,15 +482,15 @@
SUMMARY_OK="$SUMMARY_OK $SUF"
else
if [ "$V" -gt 0 ] ; then
- echo -e -n "$outbuf"
- echo -e "test run $SUF: $fail_count test failures. FAIL.\n"
+ echo $ECHO_E -n "$outbuf"
+ echo $ECHO_E "test run $SUF: $fail_count test failures. FAIL.\n"
fi
SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
exit_code=30
fi
if [ -n "$test_cleanup" ]; then
- echo -e "cleaning up: '$test_cleanup'"
+ echo $ECHO_E "cleaning up: '$test_cleanup'"
eval $test_cleanup
fi
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1753?usp=email
To unsubscribe, or for help writing mail filters, visit
http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I746bd8c0fa3496d23569cde496438fc4189600fe
Gerrit-Change-Number: 1753
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel