Date: Sun, 6 Dec 2015 14:09:31 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291903 - head/bin/sh/tests/parameters Message-ID: <201512061409.tB6E9VR4008123@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Sun Dec 6 14:09:31 2015 New Revision: 291903 URL: https://svnweb.freebsd.org/changeset/base/291903 Log: sh: Add limited test for ${#@} and ${#*}. POSIX leaves the result of expanding ${#@} and ${#*} unspecified, but ensure it is numeric. Added: head/bin/sh/tests/parameters/positional9.0 (contents, props changed) Modified: head/bin/sh/tests/parameters/Makefile Modified: head/bin/sh/tests/parameters/Makefile ============================================================================== --- head/bin/sh/tests/parameters/Makefile Sun Dec 6 14:07:57 2015 (r291902) +++ head/bin/sh/tests/parameters/Makefile Sun Dec 6 14:09:31 2015 (r291903) @@ -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 Added: head/bin/sh/tests/parameters/positional9.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/parameters/positional9.0 Sun Dec 6 14:09:31 2015 (r291903) @@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512061409.tB6E9VR4008123>