From owner-freebsd-standards@FreeBSD.ORG Mon Aug 12 21:55:06 2013 Return-Path: Delivered-To: freebsd-standards@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 69564963 for ; Mon, 12 Aug 2013 21:55:06 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E9C442E5A for ; Mon, 12 Aug 2013 21:55:05 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id BADEE3592F8; Mon, 12 Aug 2013 23:55:02 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id 910F728494; Mon, 12 Aug 2013 23:55:02 +0200 (CEST) Date: Mon, 12 Aug 2013 23:55:02 +0200 From: Jilles Tjoelker To: Jens Schweikhardt Subject: Re: standards/181240: /bin/sh choking on a certain construct Message-ID: <20130812215502.GA53860@stack.nl> References: <201308122110.r7CLA1lH005924@freefall.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201308122110.r7CLA1lH005924@freefall.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-standards@FreeBSD.org X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Aug 2013 21:55:06 -0000 On Mon, Aug 12, 2013 at 09:10:01PM +0000, Jens Schweikhardt wrote: > The following reply was made to PR standards/181240; it has been noted > by GNATS. > From: Jens Schweikhardt > To: Tamas TEVESZ > Cc: freebsd-gnats-submit@FreeBSD.org > Subject: Re: standards/181240: /bin/sh choking on a certain construct > Date: Mon, 12 Aug 2013 23:06:43 +0200 > On Mon, Aug 12, 2013 at 01:54:02PM +0000, Tamas TEVESZ wrote: > # >How-To-Repeat: > # /bin/sh -c 'echo foo || >&2 | cat' > # > # (Or, if you have misc/mc installed, hit ^[3 on a .diff/.patch/.so etc. file for which mc calls /usr/local/libexec/mc/ext.d/misc.sh) > A simpler invocation is > $ >x | cat > Syntax error: "|" unexpected > If I read the SUS shell grammar correctly, a lone redirection cannot be > a simple command in a pipe, so this is an extension that the other > shells accept. I'm not sure if this is a particular useful extension. I think the PR is valid. A lone redirection is a valid simple command, everywhere a simple command may occur. In the grammar, the simple_command consists of a single cmd_prefix which consists of a single io_redirect. I fixed this for & in 2010 and fixing it for | as well is not hard. The same problem exists for ;; and ;&. See the below patch. I plan to commit it soon. Index: bin/sh/parser.c =================================================================== --- bin/sh/parser.c (revision 253911) +++ bin/sh/parser.c (working copy) @@ -577,6 +577,9 @@ TRACE(("expecting DO got %s %s\n", tokname[got], g case TSEMI: case TAND: case TOR: + 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 ;'. Index: tools/regression/bin/sh/parser/only-redir2.0 =================================================================== --- tools/regression/bin/sh/parser/only-redir2.0 (revision 0) +++ tools/regression/bin/sh/parser/only-redir2.0 (working copy) @@ -0,0 +1,2 @@ +# $FreeBSD$ +