From afa63b2dcdc9b9d0183ffd84599ea5d4ad94d639 Mon Sep 17 00:00:00 2001 From: Michael Tokarev Date: Sun, 10 Nov 2013 22:01:38 +0100 Subject: [PATCH] fix bashisms in testsuite/ These places use ${var/search/replace}, $((n++) and `type -p' constructs which are not-so-standard. Replace with equivalent constructs. Signed-off-by: Michael Tokarev Signed-off-by: Bernhard Reutner-Fischer --- testsuite/hostid/hostid-works | 10 ++++------ testsuite/md5sum.tests | 6 +++--- testsuite/testing.sh | 8 ++++---- testsuite/which/which-uses-default-path | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/testsuite/hostid/hostid-works b/testsuite/hostid/hostid-works index bcfd717af..8c20bdfcc 100644 --- a/testsuite/hostid/hostid-works +++ b/testsuite/hostid/hostid-works @@ -1,8 +1,6 @@ h=x$(busybox hostid) # Is $h a sequence of hex numbers? -x="${h//[0123456789abcdef]/x}" -x="${x//xxx/x}" -x="${x//xxx/x}" -x="${x//xxx/x}" -x="${x//xx/x}" -test x"$x" = x"x" +case "$h" in + x*[!0-9a-f]*) false;; + *) true;; +esac diff --git a/testsuite/md5sum.tests b/testsuite/md5sum.tests index 1068b083f..6c75b6d1c 100755 --- a/testsuite/md5sum.tests +++ b/testsuite/md5sum.tests @@ -30,13 +30,13 @@ result=`( n=0 while test $n -le 999; do echo "$text" | head -c $n | "$sum" - : $((n++)) + n=$(($n+1)) done | "$sum" )` if test x"$result" = x"$expected -"; then - echo "PASS: $sum" - exit 0 + echo "PASS: $sum" + exit 0 fi echo "FAIL: $sum (r:$result exp:$expected)" diff --git a/testsuite/testing.sh b/testsuite/testing.sh index e7e64e58b..f5b756947 100644 --- a/testsuite/testing.sh +++ b/testsuite/testing.sh @@ -56,10 +56,10 @@ optional() { SKIP= while test "$1"; do - if test x"${OPTIONFLAGS/*:$1:*/y}" != x"y"; then - SKIP=1 - return - fi + case "${OPTIONFLAGS}" in + *:$1:*) ;; + *) SKIP=1; return ;; + esac shift done } diff --git a/testsuite/which/which-uses-default-path b/testsuite/which/which-uses-default-path index 63ceb9f8f..349583dcc 100644 --- a/testsuite/which/which-uses-default-path +++ b/testsuite/which/which-uses-default-path @@ -1,4 +1,4 @@ -BUSYBOX=$(type -p busybox) +BUSYBOX=$(command -pv busybox) SAVED_PATH=$PATH unset PATH $BUSYBOX which ls