zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: Surprising parsing result with anonymous functions and for loops
Date: Fri, 26 Sep 2014 09:58:02 +0100	[thread overview]
Message-ID: <20140926095802.15b1e388@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20140925145243.147928cd@pwslap01u.europe.root.pri>

On Thu, 25 Sep 2014 14:52:43 +0100
Peter Stephenson <p.stephenson@samsung.com> wrote:
> On Thu, 25 Sep 2014 15:21:43 +0200
> Mikael Magnusson <mikachu@gmail.com> wrote:
> > On 25 September 2014 13:39, Peter Stephenson <p.stephenson@samsung.com> wrote:
> > > On Thu, 25 Sep 2014 12:02:55 +0200
> > > Mikael Magnusson <mikachu@gmail.com> wrote:
> > >> Okay, but does anyone at least agree that doing alias expansion at
> > >> that point is highly surprising?
> > >
> > > You mean regardless of function behaviour?
> > >
> > > % alias foo=bar
> > > % for i in 1; do : ; done foo
> > > zsh: parse error near `bar'
> 
> I think the change is theoretically correct anyway; we shouldn't be
> looking for commands at those points, we should only be looking for
> arguments, even though only special arguments like redirections are
> handled here, so actually it's moot for most non-error cases.

The only non-error case I can think of that this would effect is if you
add a non-global alias for something like "2>&1", though I can't think
of a good use for this (unlike a global alias).  You now wouldn't be
able to use that in the cases in question.  But I don't think you'd
expect to.

I'll commit this, but in case there are oddities that aren't picked up
by the tests here's a list of the cases that changed for future
reference.  "After" implies parsing for the immediately following
non-whitespace token.

for:
  - after "done"
  - after "}" in the alternative syntax
  - after "end" in the CSH syntax.

if:
  - after "fi" encountered without else ) two different cases
  - after "fi" encountered after else   )     in the code
  - after "}" encountered after else in the alternative syntax

while and repeat:
  - after "done"
  - after "}" in the alternative syntax

pws


  reply	other threads:[~2014-09-26  8:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-24 14:07 Mikael Magnusson
2014-09-24 14:26 ` Peter Stephenson
2014-09-24 22:02   ` Mikael Magnusson
2014-09-25  5:35     ` Bart Schaefer
2014-09-25  5:53       ` Bart Schaefer
2014-09-25 10:02       ` Mikael Magnusson
2014-09-25 11:39         ` Peter Stephenson
2014-09-25 13:21           ` Mikael Magnusson
2014-09-25 13:52             ` Peter Stephenson
2014-09-26  8:58               ` Peter Stephenson [this message]
     [not found] ` <CAKjp4B7Gy9f2RCYzn8G6i+ADh_p7GWZEv1x_Cd0eR3Ggxv+APw@mail.gmail.com>
2014-09-24 19:14   ` Fwd: " Clint Hepner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140926095802.15b1e388@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).