mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
sh: Add limited test for ${#@} and ${#*}.
POSIX leaves the result of expanding ${#@} and ${#*} unspecified, but ensure
it is numeric.
This commit is contained in:
parent
eab02f464a
commit
d253cfe3b2
2 changed files with 19 additions and 0 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
18
bin/sh/tests/parameters/positional9.0
Normal file
18
bin/sh/tests/parameters/positional9.0
Normal file
|
|
@ -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
|
||||
Loading…
Reference in a new issue