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

Re: FAQ and other shell syntax



On Wed, Jan 12, 2005 at 11:21:14AM +0000, Stephane Chazelas wrote:
> read at
> http://zsh.sunsite.dk/FAQ/zshfaq01.html#l8
>
>      [ x$ZSH_VERSION = x -a -f $HOME/bin/zsh ] && exec $HOME/bin/zsh -l
>
> It should be noted that contrary to zsh, other shells need their
> variables to be quotes (my home dir is "/home/Stephane Chazelas").
>
> if [ -z "$ZSH_VERSION" ] \
>   && [ -f "$HOME/bin/zsh" ] \
>   && [ -x "$HOME/bin/zsh" ]; then
>   SHELL=$HOME/bin/zsh; export SHELL
>   exec "$SHELL" -l
> fi

I find it safer to actually try running `zsh --version' rather than
using -f and -x.  First, because `test -x' is not supported
everywhere.  Second, because `exec zsh' might fail badly if some
shared library is missing.

I have the following in my .tcshrc:

# ...
# skip remaining setup if not an interactive shell
if ($?USER == 0 || $?prompt == 0) exit
# ...
# Is there a working zsh in PATH?
(zsh --version) >&/dev/null && exec zsh
# Otherwise try know locations.
(/bin/zsh --version) >&/dev/null && exec /bin/zsh
(/usr/bin/zsh --version) >&/dev/null && exec /usr/bin/zsh

(obviously that would look better with SHELL and -l)



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