From da1b2a7081eb2791f3a675945c42d7f3189ef752 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Sun, 9 Aug 2026 17:30:41 +0200 Subject: [PATCH] t_client.sh.in: Use printf instead of echo -e In some shells the echo builtin doesn't interpret -e as an argument, it just outputs it as a string. Examples for shells I have observed this with are dash on Ubuntu and /bin/sh on macOS. Use printf instead which should have better consistency across shells and operating systems. Change-Id: I746bd8c0fa3496d23569cde496438fc4189600fe Signed-off-by: Frank Lichtenheld Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1753 Message-Id: <20260809153046.14738-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg38258.html Signed-off-by: Gert Doering --- tests/t_client.sh.in | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in index 7233187f8..0254c0c32 100755 --- a/tests/t_client.sh.in +++ b/tests/t_client.sh.in @@ -132,21 +132,20 @@ output_start() { case $V in 0) outbuf="" ;; # no per-test output at all - 1) echo -e "$@" # compact, details only on failure + 1) printf "$@\n" # compact, details only on failure outbuf="\n" ;; - *) echo -e "\n$@\n" ;; # print all, with a bit formatting + *) printf "\n$@\n" ;; # print all, with a bit formatting esac } output() { - NO_NL=''; if [ "X$1" = "X-n" ] ; then NO_NL=$1 ; shift ; fi + END_NL="\n"; if [ "X$1" = "X-n" ] ; then END_NL="" ; shift ; fi case $V in 0) ;; # no per-test output at all - 1) outbuf="$outbuf$@" # print details only on failure - test -z "$NO_NL" && outbuf="$outbuf\n" + 1) outbuf="$outbuf$@${END_NL}" # print details only on failure ;; - *) echo -e $NO_NL "$@" ;; # print everything + *) printf "$@${END_NL}" ;; # print everything esac } @@ -340,7 +339,7 @@ do else output "skip check failed, SKIP test $SUF." SUMMARY_SKIP="$SUMMARY_SKIP $SUF" - echo -e "$outbuf" ; continue + printf "$outbuf" ; continue fi fi @@ -361,7 +360,7 @@ do 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 + printf "$outbuf" ; continue fi pidfile="${top_builddir}/tests/$LOGDIR/openvpn-$SUF.pid" @@ -407,7 +406,7 @@ do trap - 0 1 2 3 15 SUMMARY_FAIL="$SUMMARY_FAIL $SUF" exit_code=30 - echo -e "$outbuf" ; continue + printf "$outbuf" ; continue fi # make sure openvpn client is terminated in case shell exits @@ -470,15 +469,15 @@ do 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" + printf "$outbuf" + echo "test run $SUF: $fail_count test failures. FAIL." fi SUMMARY_FAIL="$SUMMARY_FAIL $SUF" exit_code=30 fi if [ -n "$test_cleanup" ]; then - echo -e "cleaning up: '$test_cleanup'" + echo "cleaning up: '$test_cleanup'" eval $test_cleanup fi -- 2.47.3