From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7164 invoked by alias); 26 Sep 2014 08:58:11 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 33251 Received: (qmail 29007 invoked from network); 26 Sep 2014 08:58:07 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f5-b7f776d000003e54-c9-54252a9c4b34 Date: Fri, 26 Sep 2014 09:58:02 +0100 From: Peter Stephenson To: zsh workers Subject: Re: Surprising parsing result with anonymous functions and for loops Message-id: <20140926095802.15b1e388@pwslap01u.europe.root.pri> In-reply-to: <20140925145243.147928cd@pwslap01u.europe.root.pri> References: <20140924152625.73dfa6d9@pwslap01u.europe.root.pri> <20140925123906.53c1d853@pwslap01u.europe.root.pri> <20140925145243.147928cd@pwslap01u.europe.root.pri> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphluLIzCtJLcpLzFFi42I5/e/4Zd05WqohBtdmy1gcbH7I5MDoserg B6YAxigum5TUnMyy1CJ9uwSujJ9PzjIXzOSruNeyg62BsYu7i5GTQ0LARGJDaz8LhC0mceHe erYuRi4OIYGljBJb7l5lhHCWM0lc2PmfFaSKRUBV4uDjl0wgNpuAocTUTbMZQWwRoHjz939A kzg4hAV8JfpeioKEeQXsJb6vXANWwingIHHr9RewZUICE1gk+j+wgdj8AvoSV/9+YoI4wl5i 5pUzjBC9ghI/Jt8Dq2cW0JLYvK2JFcKWl9i85i3zBEaBWUjKZiEpm4WkbAEj8ypG0dTS5ILi pPRcI73ixNzi0rx0veT83E2MkBD8uoNx6TGrQ4wCHIxKPLw31qmECLEmlhVX5h5ilOBgVhLh NVJQDRHiTUmsrEotyo8vKs1JLT7EyMTBKdXAGFUZnHT6pcibIuuE7WI5DmWqNaE/X57Kz45o 43janRt2a/uM2aXhNzyXsa5U8rAQO/d+98E7vxRVTTYLlfstbu0+4rT9TMkJi9y5bgmpqy5w 9G27k7uZq0VReq/jVI+/FjyN9e99apN3Ja+YfHzdlxMHJjzrean5RcxyW4TxR/YV9X6dPRc/ KbEUZyQaajEXFScCACjUxA8fAgAA On Thu, 25 Sep 2014 14:52:43 +0100 Peter Stephenson wrote: > On Thu, 25 Sep 2014 15:21:43 +0200 > Mikael Magnusson wrote: > > On 25 September 2014 13:39, Peter Stephenson wrote: > > > On Thu, 25 Sep 2014 12:02:55 +0200 > > > Mikael Magnusson 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