From 7da17612246437d1b1dc6f67639ecdc25f0eb3fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Wed, 27 Aug 2008 10:54:21 +0200 Subject: [PATCH] (print_raw, print_nl): Use printf. Updated testcases with comments; comments are now preserved. Rev: nettle/testsuite/sexp-conv-test:1.2 --- testsuite/sexp-conv-test | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/testsuite/sexp-conv-test b/testsuite/sexp-conv-test index 7d7cc6bc..eed19e5a 100755 --- a/testsuite/sexp-conv-test +++ b/testsuite/sexp-conv-test @@ -4,28 +4,12 @@ if [ -z "$srcdir" ] ; then srcdir=`pwd` fi -# echo -n is not portable - -if [ "`echo -n ''`" = "" ]; then - n='-n'; c='' -elif [ "`echo '\c'`" = "" ]; then - n=''; c='\c' -else - echo >&2 'Neither echo -n nor echo \c seems to work.' - exit 1 -fi - -# Doesn't work if $1 contains print_raw () { - echo $n "$1$c" > "$2" + printf "%s" "$1" > "$2" } -# Using a here-document seems more robust. However, I don't know how -# to get rid of the final newline, so we can't use it exclusively. print_nl () { - cat >"$2" <<EOF -$1 -EOF + printf "%s\n" "$1" > "$2" } test_advanced () { @@ -106,7 +90,13 @@ test_advanced '()' '()' test_advanced '(foo bar baz)' '(foo bar baz)' test_advanced '; comment -()' '()' +()' '; comment + +()' +test_advanced '(foo ; gazonk +bar)' '(foo ; gazonk + + bar)' test_advanced '(foo[bar]foo)' '(foo [bar]foo)' -- GitLab