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

Re: environment settings



On 2008-06-23 16:24:31 +0100, Stephane Chazelas wrote:
> Note that $SHELL is called for that purpose in a number of
> places such as vi's :!, ftp's !,

In those cases, sourcing the .zshenv doesn't hurt. On the contrary,
it allows to define some aliases or whatever the user wishes.

> ssh host 'cmd line'... not only gdb.

ssh runs the user's default login shell on the remote host, which can
be different from $SHELL. And this was the problem I was mentioning
with bash: there's no way to set up some environment variables. So,
with bash, "ssh -t host some_program" won't work if some_program is
in the user's $HOME/bin directory, even though the user always has
this directory in his $PATH.

> It's true it would be nice to be able to distinguish between zsh
> instances that are meant to be user shells that is that are
> meant to parse command lines given by the user and instances
> that are meant to run canonical zsh code where the user is not
> meant to alter the zsh behavior (as in zsh scripts, zsh -c ...) 

Yes, but I doubt this would solve all the problems. When I use
"zsh -c", I want .zshenv to be sourced (the reason is that I
sometimes do "ssh [-t] host zsh -c ..." and the .zshenv is the
*only* way to set up environment variables -- but I could also
source my .zshenv at the beginning of the command string).

> csh solves that with the -f option without which every csh
> instance is sourcing .cshrc (so csh scripts have #! /bin/csh
> -f).

But this solution needs to hardcode the csh path in the script.
Something like "#!/usr/bin/env csh -f" doesn't work everywhere.

> With zsh, you could solve that by having $SHELL be
> /path/to/user-zsh, user-zsh being a link to zsh and ~/.zshenv
> having something like:
> 
> [[ $0 != (*/|)user-zsh || -o interactive ]] ||
>   . "${ZDOTDIR:-$HOME}/.zshrc"
> 
> (not tested but you get the idea).

Yes, nice idea.

Concerning gdb (which is an exception), I could write a wrapper that
sets some environment variable, which could be tested in the .zshenv
to do what I want exactly.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)



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