On Thu, Jul 29, 2010 at 02:20:29PM +0200, Denys Vlasenko wrote: >On Thu, Jul 29, 2010 at 10:27 AM, Leonid Lisovskiy <[email protected]> wrote: >> As I can see, there were a lot of scripts (expand.tests for example) >> which uses old scheme: >> >> test -f "$bindir/.config" && . "$bindir/.config" >> ... >> test x"$CONFIG_UNICODE_SUPPORT" = x"y" \ >> && test x"$CONFIG_UNICODE_USING_LOCALE" != x"y" \ >> >> probably, it should be converted to new scheme with "optional" clause, >> but I'm not sure. > >I wonder how would you express that UNICODE_USING_LOCALE should NOT be on >with "optional". > >Also, "optional" uses bashism ${var/foo/bar}: > >test x"${OPTIONFLAGS/*:$1:*/y}" != x"y" > >which was VERY SLOW in ash (it had CUBIC run time growth relative >OPTIONFLAGS length). I fixed it in ash. > >hush does not even support ${var/foo/bar} yet. > >I don't like "optional" thing because of these problems.
my initial impl of the formerly "config_is_set" didn't use bashism, but whatever. What about the attached that does away with bashism (but taking the penalty in runtime due to several subshell-spawning) and supports !SOMETHING ? HTH && cheers,
>From 0b412b0c40111ecd28e4d524e96c39f23c5954fa Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer <[email protected]> Date: Thu, 29 Jul 2010 21:22:12 +0200 Subject: [PATCH] testsuite: fix bashism and support !thing Signed-off-by: Bernhard Reutner-Fischer <[email protected]> --- testsuite/testing.sh | 23 ++++++++++++++++++----- 1 files changed, 18 insertions(+), 5 deletions(-) diff --git a/testsuite/testing.sh b/testsuite/testing.sh index f907dea..6e90a23 100644 --- a/testsuite/testing.sh +++ b/testsuite/testing.sh @@ -51,17 +51,30 @@ test x"$ECHO" != x"" || { } # Helper functions +# optional REQUIREDOPTION !NOTTHISOPTION BUTTHATOPTION +# turn off previous optionals: +# optional +# change requirements: +# optional REQUIREDOPTION2 !NOTTHISOPTION BUTTHATOPTION optional() { - SKIP= + NUMSKIPS=0 + NUMTESTS=$# while test "$1"; do - if test x"${OPTIONFLAGS/*:$1:*/y}" != x"y"; then - SKIP=1 - return - fi + OP=$(echo "x"${1} | grep -q "x!" && echo "!") + test "x"${OP} = "x" && FLAG=${1} || \ + FLAG=$(printf "\b%s" ${1}) + # XXX: undo damage of 'export OPTIONFLAGS' mangling + FLAG=$(echo $FLAG | sed -e 's/^CONFIG_//') + SET=$(echo ${OPTIONFLAGS} | grep -q ":${FLAG}:" && echo y) + case "${SET}${OP}" in + ""|"y!") ;; + *) NUMSKIPS=$(expr $NUMSKIPS + 1) ;; + esac shift done + test $NUMSKIPS -eq $NUMTESTS && SKIP= || SKIP=1 } # The testing function -- 1.7.1
_______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
