From ca7db6cb8000cc283fcee7899140d2fc892b0296 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 24 Mar 2010 09:05:27 +0100 Subject: [PATCH] tests: shell script portability and clean-up * tests/test-lib.sh: "echo -n" is not portable. Use printf instead. Remove unnecessary uses of "eval-in-subshell" (subshell is sufficient). Remove uses of tests' -a operator; it is not portable. Instead, use "test cond && test cond2". * tests/schematestutils.sh: Replace use of test's -a. --- tests/schematestutils.sh | 2 +- tests/test-lib.sh | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/schematestutils.sh b/tests/schematestutils.sh index 301b9ebc64..f1728578ee 100644 --- a/tests/schematestutils.sh +++ b/tests/schematestutils.sh @@ -21,7 +21,7 @@ do ret=$? test_result $n $(basename $(dirname $xml))"/"$(basename $xml) $ret - if test "$verbose" = "1" -a $ret != 0 ; then + if test "$verbose" = "1" && test $ret != 0 ; then echo -e "$cmd\n$result" fi if test "$ret" != 0 ; then diff --git a/tests/test-lib.sh b/tests/test-lib.sh index 57fd43893d..28b830eb31 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -19,7 +19,7 @@ test_intro() name=$1 if test "$verbose" = "0" ; then echo "TEST: $name" - echo -n " " + printf " " fi } @@ -29,15 +29,15 @@ test_result() name=$2 status=$3 if test "$verbose" = "0" ; then - mod=`eval "expr \( $counter - 1 \) % 40"` - if test "$counter" != 1 -a "$mod" = 0 ; then - printf " %-3d\n" `eval "expr $counter - 1"` - echo -n " " + mod=`expr \( $counter + 40 - 1 \) % 40` + if test "$counter" != 1 && test "$mod" = 0 ; then + printf " %-3d\n" `expr $counter - 1` + printf " " fi if test "$status" = "0" ; then - echo -n "." + printf "." else - echo -n "!" + printf "!" fi else if test "$status" = "0" ; then @@ -54,11 +54,11 @@ test_final() status=$2 if test "$verbose" = "0" ; then - mod=`eval "expr \( $counter + 1 \) % 40"` - if test "$mod" != "0" -a "$mod" != "1" ; then + mod=`expr \( $counter + 1 \) % 40` + if test "$mod" != "0" && test "$mod" != "1" ; then for i in `seq $mod 40` do - echo -n " " + printf " " done fi if test "$status" = "0" ; then