[Openvpn-devel] [S] Change in openvpn[master]: t_client.sh.in: Use printf instead of echo -e

"cron2 \(Code Review\) via Openvpn-devel" <[email protected]>
Newsgroups net.sourceforge.lists.openvpn-devel
Message-ID <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1753?usp=email )

Change subject: t_client.sh.in: Use printf instead of echo -e
......................................................................

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 <[email protected]>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1753
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg38258.html
Signed-off-by: Gert Doering <[email protected]>
---
M tests/t_client.sh.in
1 file changed, 11 insertions(+), 12 deletions(-)




diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in
index 7233187..0254c0c3 100755
--- a/tests/t_client.sh.in
+++ b/tests/t_client.sh.in
@@ -132,21 +132,20 @@
 {
     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 @@
         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 @@
 	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 @@
 	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 @@
 	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
 

-- 
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: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I746bd8c0fa3496d23569cde496438fc4189600fe
Gerrit-Change-Number: 1753
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.