diff options
author | jilles <jilles@FreeBSD.org> | 2015-12-06 14:09:31 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2015-12-06 14:09:31 +0000 |
commit | bfe5e9c164293f28ef6fa5adf6eb185a85e9731d (patch) | |
tree | cc4945c4e327e29126569552f8f43bb51d9d35c2 /bin/sh | |
parent | 070b607d8829bd9c06ba0c2ba20e89bbba1a6ff0 (diff) | |
download | FreeBSD-src-bfe5e9c164293f28ef6fa5adf6eb185a85e9731d.zip FreeBSD-src-bfe5e9c164293f28ef6fa5adf6eb185a85e9731d.tar.gz |
sh: Add limited test for ${#@} and ${#*}.
POSIX leaves the result of expanding ${#@} and ${#*} unspecified, but ensure
it is numeric.
Diffstat (limited to 'bin/sh')
-rw-r--r-- | bin/sh/tests/parameters/Makefile | 1 | ||||
-rw-r--r-- | bin/sh/tests/parameters/positional9.0 | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/bin/sh/tests/parameters/Makefile b/bin/sh/tests/parameters/Makefile index d496492..528697d 100644 --- a/bin/sh/tests/parameters/Makefile +++ b/bin/sh/tests/parameters/Makefile @@ -21,6 +21,7 @@ FILES+= positional5.0 FILES+= positional6.0 FILES+= positional7.0 FILES+= positional8.0 +FILES+= positional9.0 FILES+= pwd1.0 FILES+= pwd2.0 diff --git a/bin/sh/tests/parameters/positional9.0 b/bin/sh/tests/parameters/positional9.0 new file mode 100644 index 0000000..8571bfa --- /dev/null +++ b/bin/sh/tests/parameters/positional9.0 @@ -0,0 +1,18 @@ +# $FreeBSD$ +# Although POSIX leaves the result of expanding ${#@} and ${#*} unspecified, +# make sure it is at least numeric. + +set -- bb cc ddd +set -f +lengths=${#*}${#@}"${#*}${#@}"$(echo ${#*}${#@}"${#*}${#@}") +IFS= +lengths=$lengths${#*}${#@}"${#*}${#@}"$(echo ${#*}${#@}"${#*}${#@}") +case $lengths in +*[!0-9]*) + printf 'bad: %s\n' "$lengths" + exit 3 ;; +????????????????*) ;; +*) + printf 'too short: %s\n' "$lengths" + exit 3 ;; +esac |