6c1aee8
commit f6bc5b14bd193859851d15a049bafb1007acd288
6c1aee8
Author: Andreas Gruenbacher <agruen@gnu.org>
6c1aee8
Date:   Wed Feb 7 12:10:41 2018 +0100
6c1aee8
6c1aee8
    Test suite compatibility fixes
6c1aee8
    
6c1aee8
    * tests/crlf-handling, tests/git-cleanup, tests/test-lib.sh: Use printf
6c1aee8
    instead of echo -e / echo -n for compatibility with systems that don't
6c1aee8
    support these echo options.
6c1aee8
    * tests/merge: Minor other cleanups.
6c1aee8
6c1aee8
diff --git a/tests/crlf-handling b/tests/crlf-handling
6c1aee8
index 239149c..c192cac 100644
6c1aee8
--- a/tests/crlf-handling
6c1aee8
+++ b/tests/crlf-handling
6c1aee8
@@ -14,7 +14,7 @@ use_local_patch
6c1aee8
 use_tmpdir
6c1aee8
 
6c1aee8
 lf2crlf() {
6c1aee8
-    while read l; do echo -e "$l\r"; done
6c1aee8
+    while read l; do printf "%s\r\n" "$l"; done
6c1aee8
 }
6c1aee8
 
6c1aee8
 echo 1 > a
6c1aee8
diff --git a/tests/git-cleanup b/tests/git-cleanup
6c1aee8
index 2e3e4c6..ca527a1 100644
6c1aee8
--- a/tests/git-cleanup
6c1aee8
+++ b/tests/git-cleanup
6c1aee8
@@ -36,8 +36,8 @@ BAD PATCH
6c1aee8
 EOF
6c1aee8
 
6c1aee8
 echo 1 > f
6c1aee8
-echo -n '' > g
6c1aee8
-echo -n '' > h
6c1aee8
+printf '' > g
6c1aee8
+printf '' > h
6c1aee8
 
6c1aee8
 check 'patch -f -i 1.diff || echo status: $?' <
6c1aee8
 patching file f
6c1aee8
diff --git a/tests/merge b/tests/merge
6c1aee8
index 22d787b..b628891 100644
6c1aee8
--- a/tests/merge
6c1aee8
+++ b/tests/merge
6c1aee8
@@ -30,30 +30,28 @@ x2() {
6c1aee8
     while test $# -gt 0 && test "$1" != -- ; do
6c1aee8
 	echo "$1"
6c1aee8
 	shift
6c1aee8
-    done > a.sed
6c1aee8
-    echo "$body" | sed -f a.sed > b
6c1aee8
+    done > b.sed
6c1aee8
+    echo "$body" | sed -f b.sed > b
6c1aee8
     shift
6c1aee8
     while test $# -gt 0 ; do
6c1aee8
 	echo "$1"
6c1aee8
 	shift
6c1aee8
-    done > b.sed
6c1aee8
-    echo "$body" | sed -f b.sed > c
6c1aee8
-    rm -f a.sed b.sed
6c1aee8
+    done > c.sed
6c1aee8
+    echo "$body" | sed -f c.sed > c
6c1aee8
+    rm -f b.sed c.sed
6c1aee8
     output=`diff -u a b | patch $ARGS -f c`
6c1aee8
     status=$?
6c1aee8
     echo "$output" | sed -e '/^$/d' -e '/^patching file c$/d'
6c1aee8
     cat c
6c1aee8
-    test $status == 0 || echo "Status: $status"
6c1aee8
+    test $status = 0 || echo "Status: $status"
6c1aee8
 }
6c1aee8
 
6c1aee8
 x() {
6c1aee8
-    ARGS="$ARGS --merge" x2 "$@"
6c1aee8
+    ARGS="--merge" x2 "$@"
6c1aee8
     echo
6c1aee8
-    ARGS="$ARGS --merge=diff3" x2 "$@"
6c1aee8
+    ARGS="--merge=diff3" x2 "$@"
6c1aee8
 }
6c1aee8
 
6c1aee8
-unset ARGS
6c1aee8
-
6c1aee8
 # ==============================================================
6c1aee8
 
6c1aee8
 check 'x 3' <
6c1aee8
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
6c1aee8
index be0d7e3..661da52 100644
6c1aee8
--- a/tests/test-lib.sh
6c1aee8
+++ b/tests/test-lib.sh
6c1aee8
@@ -41,7 +41,7 @@ use_local_patch() {
6c1aee8
 
6c1aee8
     eval 'patch() {
6c1aee8
 	if test -n "$GDB" ; then
6c1aee8
-	  echo -e "\n" >&3
6c1aee8
+	  printf "\n\n" >&3
6c1aee8
 	  gdbserver localhost:53153 $PATCH "$@" 2>&3
6c1aee8
 	else
6c1aee8
           $PATCH "$@"
6c1aee8
@@ -113,22 +113,15 @@ cleanup() {
6c1aee8
     exit $status
6c1aee8
 }
6c1aee8
 
6c1aee8
-if test -z "`echo -n`"; then
6c1aee8
-    if eval 'test -n "${BASH_LINENO[0]}" 2>/dev/null'; then
6c1aee8
-	eval '
6c1aee8
-	    _start_test() {
6c1aee8
-		echo -n "[${BASH_LINENO[2]}] $* -- "
6c1aee8
-	    }'
6c1aee8
-    else
6c1aee8
-	eval '
6c1aee8
-	    _start_test() {
6c1aee8
-		echo -n "* $* -- "
6c1aee8
-	    }'
6c1aee8
-    fi
6c1aee8
+if eval 'test -n "${BASH_LINENO[0]}" 2>/dev/null'; then
6c1aee8
+    eval '
6c1aee8
+	_start_test() {
6c1aee8
+	    printf "[${BASH_LINENO[2]}] %s -- " "$*"
6c1aee8
+	}'
6c1aee8
 else
6c1aee8
     eval '
6c1aee8
 	_start_test() {
6c1aee8
-	    echo "* $*"
6c1aee8
+	    printf "* %s -- " "$*"
6c1aee8
 	}'
6c1aee8
 fi
6c1aee8