From: Ruediger Meier Date: Wed, 17 Feb 2016 14:01:21 +0000 (+0100) Subject: tests: fix ts_option helpers X-Git-Tag: v2.28-rc1~85^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4303124ad5879a100c6ddd6c28c74164de8e7afb;p=thirdparty%2Futil-linux.git tests: fix ts_option helpers These two problems should be fixed now: - BSD awk only accepts 1-char field seperator - ts_has_option() did not returned "yes" if an option was given multiple times Signed-off-by: Ruediger Meier --- diff --git a/tests/functions.sh b/tests/functions.sh index d3367e1a53..e639e73628 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -158,13 +158,15 @@ function ts_has_option { fi # or just check the global command line options - echo -n $ALL | sed 's/ //g' | awk 'BEGIN { FS="="; RS="--" } /('$NAME'$|'$NAME'=)/ { print "yes" }' + if [[ $ALL =~ ([$' \t\n']|^)--$NAME([$'= \t\n']|$) ]]; then echo yes; fi } function ts_option_argument { NAME="$1" ALL="$2" - echo -n $ALL | sed 's/ //g' | awk 'BEGIN { FS="="; RS="--" } /'$NAME'=/ { print $2 }' + + # last option wins! + echo "$ALL" | sed -n "s/.*[ \t\n]--$NAME=\([^ \t\n]*\).*/\1/p" | tail -n 1 } function ts_init_core_env {