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

Re: environment settings



On Sun, Jun 22, 2008 at 10:41:52AM +0200, Vincent Lefevre wrote:
> On 2008-06-21 13:30:50 +0100, Stephane Chazelas wrote:
> > The program to debug (here env) is run through $SHELL which
> > sources ~/.zshenv which overrides the setting of the A variable.
> > (PATH in Wayne's case).
> > 
> > It's not gdb's fault and there's nothing it can do about it.
> 
> OK, it is explained in the manual that argument building is done by
> gdb, using $SHELL:
> 
> The _arguments._
>      Specify the arguments to give your program as the arguments of the
>      `run' command.  If a shell is available on your target, the shell
>      is used to pass the arguments, so that you may use normal
>      conventions (such as wildcard expansion or variable substitution)
>      in describing the arguments.  In Unix systems, you can control
>      which shell is used with the `SHELL' environment variable.  *Note
>      Your Program's Arguments: Arguments.
> 
> So, this is even worse. For instance, if the user changes the way
> arguments are built (e.g. I use "setopt EXTENDED_GLOB" in my .zshrc),
> such options should actually be in the .zshenv to get the same
> behavior!
[...]

Note that $SHELL is called for that purpose in a number of
places such as vi's :!, ftp's !, ssh host 'cmd line'... not only
gdb.

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 ...) 

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

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).

-- 
Stéphane



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