Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Surprising parsing result with anonymous functions and for loops
On Thu, 25 Sep 2014 14:52:43 +0100
Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> On Thu, 25 Sep 2014 15:21:43 +0200
> Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> > On 25 September 2014 13:39, Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> > > On Thu, 25 Sep 2014 12:02:55 +0200
> > > Mikael Magnusson <mikachu@xxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author