From owner-svn-src-head@freebsd.org Sun Dec 6 14:09:33 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3906999A0EE; Sun, 6 Dec 2015 14:09:33 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0779A1C18; Sun, 6 Dec 2015 14:09:32 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tB6E9WT4008125; Sun, 6 Dec 2015 14:09:32 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tB6E9VR4008123; Sun, 6 Dec 2015 14:09:31 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201512061409.tB6E9VR4008123@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sun, 6 Dec 2015 14:09:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291903 - head/bin/sh/tests/parameters X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Dec 2015 14:09:33 -0000 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