From owner-svn-src-head@FreeBSD.ORG Sun Aug 25 10:57:49 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 779EC194; Sun, 25 Aug 2013 10:57:49 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 64A27272B; Sun, 25 Aug 2013 10:57:49 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7PAvnwg019150; Sun, 25 Aug 2013 10:57:49 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7PAvnNp019148; Sun, 25 Aug 2013 10:57:49 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201308251057.r7PAvnNp019148@svn.freebsd.org> From: Jilles Tjoelker Date: Sun, 25 Aug 2013 10:57:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254843 - in head: bin/sh tools/regression/bin/sh/parser 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.14 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, 25 Aug 2013 10:57:49 -0000 Author: jilles Date: Sun Aug 25 10:57:48 2013 New Revision: 254843 URL: http://svnweb.freebsd.org/changeset/base/254843 Log: sh: Disallow empty simple commands. As per POSIX, a simple command must have at least one redirection, assignment word or command word. These occured in rare cases such as eval "f()" . The extension of allowing no commands inside { }, if, while, for, etc. remains. Added: head/tools/regression/bin/sh/parser/empty-cmd1.0 (contents, props changed) Modified: head/bin/sh/parser.c Modified: head/bin/sh/parser.c ============================================================================== --- head/bin/sh/parser.c Sun Aug 25 10:57:09 2013 (r254842) +++ head/bin/sh/parser.c Sun Aug 25 10:57:48 2013 (r254843) @@ -573,7 +573,7 @@ TRACE(("expecting DO got %s %s\n", tokna synexpect(TEND); checkkwd = CHKKWD | CHKALIAS; break; - /* Handle an empty command like other simple commands. */ + /* A simple command must have at least one redirection or word. */ case TBACKGND: case TSEMI: case TAND: @@ -581,16 +581,12 @@ TRACE(("expecting DO got %s %s\n", tokna case TPIPE: case TENDCASE: case TFALLTHRU: - /* - * An empty command before a ; doesn't make much sense, and - * should certainly be disallowed in the case of `if ;'. - */ + case TEOF: + case TNL: + case TRP: if (!redir) synexpect(-1); - case TNL: - case TEOF: case TWORD: - case TRP: tokpushback++; n1 = simplecmd(rpp, redir); return n1; Added: head/tools/regression/bin/sh/parser/empty-cmd1.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/parser/empty-cmd1.0 Sun Aug 25 10:57:48 2013 (r254843) @@ -0,0 +1,3 @@ +# $FreeBSD$ + +! (eval ': || f()') 2>/dev/null