summaryrefslogtreecommitdiffstats
path: root/tests/functions.sh
diff options
context:
space:
mode:
authorRuediger Meier2016-02-17 15:01:21 +0100
committerRuediger Meier2016-02-18 12:53:48 +0100
commit4303124ad5879a100c6ddd6c28c74164de8e7afb (patch)
tree0af9d557e48cc6c85b60f91361c7b5682dafd6a5 /tests/functions.sh
parentbuild-sys: fix [g]libtoolize version for OSX (diff)
downloadkernel-qcow2-util-linux-4303124ad5879a100c6ddd6c28c74164de8e7afb.tar.gz
kernel-qcow2-util-linux-4303124ad5879a100c6ddd6c28c74164de8e7afb.tar.xz
kernel-qcow2-util-linux-4303124ad5879a100c6ddd6c28c74164de8e7afb.zip
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 <ruediger.meier@ga-group.nl>
Diffstat (limited to 'tests/functions.sh')
-rw-r--r--tests/functions.sh6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/functions.sh b/tests/functions.sh
index d3367e1a5..e639e7362 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 {