zsh-workers
 help / color / mirror / code / Atom feed
* FAQ and other shell syntax
@ 2005-01-12 11:21 Stephane Chazelas
  2005-01-12 12:22 ` Alexandre Duret-Lutz
  0 siblings, 1 reply; 2+ messages in thread
From: Stephane Chazelas @ 2005-01-12 11:21 UTC (permalink / raw)
  To: Zsh hackers list

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

and SHELL may be updated so that further xterm/screen/vi...
start the new shell instead of the login shell.

     [ -f $HOME/bin/zsh ] && {
             echo "Type Y to run zsh: \c"
             read line
             [ "$line" = Y ] && exec $HOME/bin/zsh -l
     }

Not every shell/echo support '\c'

Either use:

printf 'Type Y to run zsh: '

or

echo "Type Y to run zsh: " | tr -d '\12'

read line
if [ "x$line" = xY ]; then
  SHELL=$HOME/bin/zsh; export SHELL
  exec "$SHELL" -l
fi

regards,
Stéphane


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: FAQ and other shell syntax
  2005-01-12 11:21 FAQ and other shell syntax Stephane Chazelas
@ 2005-01-12 12:22 ` Alexandre Duret-Lutz
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Duret-Lutz @ 2005-01-12 12:22 UTC (permalink / raw)
  To: Zsh hackers list

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)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-01-12 12:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-12 11:21 FAQ and other shell syntax Stephane Chazelas
2005-01-12 12:22 ` Alexandre Duret-Lutz

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).