Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: parsing empty alternatives: case foo|) :;;
- X-seq: zsh-workers 41503
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: parsing empty alternatives: case foo|) :;;
- Date: Mon, 7 Aug 2017 07:44:58 -0700
- Cc: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>, "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=FDEZPArK2rLuNsBM7oEBVWfBnaIgsVbJxfEg9kVVb1U=; b=mAxXoKRcVJpEk/MfwB/HC8dg4ooZMk0AxL+WXS+GkM1lRFG/Mk9qxGLgubPYZE8IWc oejTvUDGoqMcWz2VbHjWNrn47g0/WiYmR1+L6WafLwE72nalNCE0JDpdDuiho+oot8nD zRUbl/FJaiDPzQS6cqEThKa4wWdaP2RMr18RfX2O0r05O2wM+IPGJWMjdMoluSnlzr3b O61Cz+XYn4MllSAAHpok5Dn6aWQLnQ40MUWxyioXCrygvnKE31GfslZo2ixFD+UtP+b9 yviLFevdF8tYcl8AW+qxCvoBN89MCfNj3b4kcK5z/a6iOe5iM0thmOKnorg8PrXTfxA6 1L7w==
- In-reply-to: <20170807152649.6a5e7d70@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20170807135641epcas3p4bc0a64f832ae7fcd76051ac198722045@epcas3p4.samsung.com> <20170807135559.odtceysgqn5qeqql@tarpaulin.shahaf.local2> <20170807152649.6a5e7d70@pwslap01u.europe.root.pri>
On Mon, Aug 7, 2017 at 7:26 AM, Peter Stephenson
<p.stephenson@xxxxxxxxxxx> wrote:
> On Mon, 7 Aug 2017 13:55:59 +0000
> Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>> % case '' in (foo|) echo yes;; esac
>> yes
>> % case '' in foo|) echo yes;; esac
>> zsh: parse error near `)'
>>
>> Why does the second case fail to parse? We (IRC) don't see any ambiguity
>> in it.
>
> I haven't checked, but I think it looks like a pipe --- at that point we
> haven't gone further down the case-specific code so that it parses the
> line specially.
Several things are going on here.
(1) The "case" syntax with no open paren and only a close paren is
from older Bourne shell
(2) The use of "|" to separate alternatives in a pattern is
zsh-specific globbing syntax, which is only active when parsing
patterns that contain a parenthesized grouping
(3) Because of both of the foregoing, when parsing the pattern in the
older syntax, recognition of "|' as a separator is not enabled -- it's
read as a simple pattern with no grouping
(4) When the newer "case" syntax with a fully parenthesized pattern
was added, the presence of the open paren gave us the parsing hook
needed to activate the grouping syntax
To put it another way, "in foo|)" is rejected for the same reason that
"in |foo)" is.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author