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?





Le 29/12/2017 à 09:47, Bart Schaefer a écrit :
You're missing a semicolon after the "C". That's the reason you get
Thank you. For some reason however, the seconde run of `export LANC=C; enable -r else; if true; then echo 'yep'; else echo 'nop'; fi; disable -r else` will return an error message with the system local anyway:

   % enable -r else;
   % export LANC=C; enable -r else; if true; then echo 'yep'; else echo
   'nop'; fi; disable -r else
   yep
   % export LANC=C; enable -r else; if true; then echo 'yep'; else echo
   'nop'; fi; disable -r else
   yep
   zsh: else: commande inconnue.

If I understand your question, the answer is "no": you can't execute
the front part of an "if" until the "fi" has been read.  See my
previous email "fully parsed before executed."
I'm rather estonished by this lake of possibility to make the equivalent of an "\n" in the middle of a line, but OK.

So the idea would be to have something like

   % whence -w else
   else: reserved
   % enable -r else; "\n" whence -w else; if true; then echo 'yep';
   else echo 'nop'; fi; disable -r else
   else: reserved
   yep
   % whence -w else
   else: none
   % enable -r else; "\n" whence -w else; if true; then echo 'yep';
   else echo 'nop'; fi; disable -r else
   else: reserved
   yep

But "\n" doesn't work here as a substitution of an effective linefeed.
(Well, you could switch to csh, which does execute every line as it
goes along, even in complex structures.  But no, not in zsh.)
Nice to know, thank you.



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