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

Re: Why does this not work in zsh?



> >Below follows a nice script, which works with ksh, bash, csh and tcsh,
> >but not with zsh :-((((
> [...]
> Erm, in zsh, you're aliasing both endif and fi to :.  I'm not surprised
> that it doesn't work.  Don't alias fi if you're using zsh.

The real probleme isn't here, it's how zsh treats the "if () then" line.

I also wanted to have a script that worked with all shells, but could
differenciate c shells from bourne shells.  I did this :

if (: != :) then
 ... bourne shell commands
else
 ... c shell commands
 alias fi "unalias fi"
endif
fi

(You'll note the cute little trick on the first line.)

This script work with sh, ksh, bash, csh, tcsh, but NOT with zsh, zsh
doesn't grok the "if () then" syntax (without a semicolon before "then")
which, event if it is nowhere documented, is accepted by sh, ksh and
bash.

For the sake of compatibility, I think this should be fixed.

As an aside, if someone has an idea on how to do what I want to do using
different means, please tell me (the bourne shell command I'm using is
just defining a function setenv, so that the rest of the script can be
processed by all shells ; this means that I can't use a subshell and
redirect its error messages to /dev/null).

-- Florent



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