Zsh Mailing List Archive
Messages sorted by:
Re: Can zsh `else` reserved keyword command be aliased and the lexem itself be repurposed as `fi` keyword command?
On a side note, the line `enable -r else; if true; then else fi; disable
-r else` won't work with two execution in a row:
▶ enable -r else; if true; then else fi; disable -r else # works
▶ export LANC=C enable -r else; if true; then else fi; disable -r else
fi # added to close the `if`
=> export: not valid in this context: -r
Is there a way to force execution at some point on a single line, as if
there was performed on two lines?
Le 28/12/2017 à 16:07, mathieu stumpf guntz a écrit :
This is mostly a copy of [a question already posted on
Maybe it might have more chance to get an answer over here.
# The problem
Following [ZSH: Call in-built function from zsh function that uses the
and [Run a command that is shadowed by an
it might be expected that a command `keyword` equivalent of what
`builtin` and `command` are doing for their respective eponymous token
category; so that
if [ -z 'love' ]; then echo 'sad world'; keyword else echo
'wonderful world'; fi
would be equivalent to
if [ -z 'love' ]; then echo 'sad world'; else echo 'wonderful
This problem was found in the following tricky scenario: being able to
replace `else` with `alie` and `fi` with `else`. See [Can zsh
for more details.
So an hypothetical attempt to implement that, if the `keyword` command
existed, would be:
alias alie="keyword else"
So, to sum it up, the question is how do you make the following peace
of zsh code works as expected by the previous command:
if [ -z 'love' ]; then echo 'sad world'; alie echo 'wonderful
# A first trail
This is not yet a working solution, but here is an idea: using the
`-r` flag of `enable` and `disable` builtin commands to change
visibility of the `else` keyword. So:
alias se='enable -r else; if'
disable -r else
alias else="fi; disable -r else"
This unfortunately doesn't work
se [ -z 'amo' ]; then echo 'trista mondo'; alie echo 'mirinda
# zsh: parse error near `fi'
This is however supposedly on the "else" alias substitution that
something break, as a non-inline version will indeed enter the
else-branch and print "mirinda mondo".
Messages sorted by: