From owner-svn-src-all@FreeBSD.ORG Sun May 9 17:10:51 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4C6231065672; Sun, 9 May 2010 17:10:51 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 3BE7D8FC16; Sun, 9 May 2010 17:10:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o49HAp8R094681; Sun, 9 May 2010 17:10:51 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o49HApol094677; Sun, 9 May 2010 17:10:51 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201005091710.o49HApol094677@svn.freebsd.org> From: Jilles Tjoelker Date: Sun, 9 May 2010 17:10:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r207824 - head/tools/regression/bin/sh/parser X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 May 2010 17:10:51 -0000 Author: jilles Date: Sun May 9 17:10:50 2010 New Revision: 207824 URL: http://svn.freebsd.org/changeset/base/207824 Log: sh: Add some parser tests. case1.0 tests POSIX requirements and one more for keywords in case statements. The others test very special cases of command substitution. These also work on stable/8. Added: head/tools/regression/bin/sh/parser/case1.0 (contents, props changed) head/tools/regression/bin/sh/parser/case2.0 (contents, props changed) head/tools/regression/bin/sh/parser/heredoc3.0 (contents, props changed) Added: head/tools/regression/bin/sh/parser/case1.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/parser/case1.0 Sun May 9 17:10:50 2010 (r207824) @@ -0,0 +1,14 @@ +# $FreeBSD$ + +keywords='if then else elif fi while until for do done { } case esac ! in' + +# Keywords can be used unquoted in case statements, except the keyword +# esac as the first pattern of a '|' alternation without a starting '('. +# (POSIX doesn't seem to require (esac) to work.) +for k in $keywords; do + eval "case $k in (foo|$k) ;; *) echo bad ;; esac" + eval "case $k in ($k) ;; *) echo bad ;; esac" + eval "case $k in foo|$k) ;; *) echo bad ;; esac" + [ "$k" = esac ] && continue + eval "case $k in $k) ;; *) echo bad ;; esac" +done Added: head/tools/regression/bin/sh/parser/case2.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/parser/case2.0 Sun May 9 17:10:50 2010 (r207824) @@ -0,0 +1,32 @@ +# $FreeBSD$ + +# Pretty much only ash derivatives can parse all of this. + +f1() { + x=$(case x in + (x|esac) ;; + (*) echo bad >&2 ;; + esac) +} +f1 +f2() { + x=$(case x in + (x|esac) ;; + (*) echo bad >&2 + esac) +} +f2 +f3() { + x=$(case x in + x|esac) ;; + *) echo bad >&2 ;; + esac) +} +f3 +f4() { + x=$(case x in + x|esac) ;; + *) echo bad >&2 + esac) +} +f4 Added: head/tools/regression/bin/sh/parser/heredoc3.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/parser/heredoc3.0 Sun May 9 17:10:50 2010 (r207824) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +# This may be expected to work, but pretty much only ash derivatives allow it. + +test "$(cat <