Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Can zsh `else` reserved keyword command be aliased and the lexem itself be repurposed as `fi` keyword command?



On Sat, Dec 30, 2017 at 9:22 AM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> Cool!  These insights from history are so very illuminating.  Mind ... that
> would seem to make it all the more possible/acceptable to do what Mathieu
> wants, it'd be a compatibility feature not some sort of abominable novelty
> the way my suggestions are abominable novelties.

It would still be pretty abominable.  Every loop structure would need
two implementations, the current one and the "csh" one, because if you
execute as you parse you can't keep the parse around for re-use -- you
have to store all the original text and re-parse it again the next
time.  Some csh implementations put the text in a hidden file and use
lseek() to move back and forth in the file for looping.  For scripts
they just use the original source file!  (I've written self-modifying
csh scripts by taking advantage of this.)

You really don't want to go there.

If you're desperate to experience something like this, you can get
close in an interactive shell by having accept-line call "eval" on the
buffer and then deciding what to do next based on the results.  It'd
be a bit tricky to retain what's already been processed once so you
know whether/when to eval it again, but something could probably be
worked out.  I'm not going to try.



Messages sorted by: Reverse Date, Date, Thread, Author