Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: environment settings
- X-seq: zsh-workers 25228
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: environment settings
- Date: Sat, 21 Jun 2008 13:30:50 +0100
- In-reply-to: <20080621113659.GA20796@xxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: zsh-workers@xxxxxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20080616074651.GB26165@marcus> <20080616080556.GA5091@xxxxxxxxxxxxxxx> <20080616123045.GC26165@marcus> <20080616124450.GC5091@xxxxxxxxxxxxxxx> <slrng5etlu.mft.joerg@xxxxxxxxxxxx> <20080621062649.GA28022@xxxxxxxxx> <20080621113659.GA20796@xxxxxxxxxxxxxxxxxxx>
On Sat, Jun 21, 2008 at 01:36:59PM +0200, Vincent Lefevre wrote:
> On 2008-06-20 23:26:49 -0700, Wayne Davison wrote:
> > The problem I ran into with setting variables in .zshenv is that they
> > can override settings you want to affect a program and/or script when
> > you don't expect it. For instance, if you need to debug a C program
> > that is run inside a script with a custom PATH. You setup the custom
> > PATH and run the C program under gdb, and discover that your PATH isn't
> > set right for the C program. This is because gdb starts the program
> > under an instance of $SHELL, which will source .zshenv, and if you're
> > setting PATH inside, that blasts the PATH setting you're expecting.
>
> I'd say that this is a bug of gdb if it doesn't restore the intended
> $PATH (a bit like what libtool does, AFAIK). BTW, isn't $SHELL for
> the user?
>
> Note this I really want zsh subshells I start to be run with a
> cleaned-up environment (this is a *user* choice).
[...]
I think this is what Wayne had in mind:
$ echo A=x >> ~/.zshenv
$ env -i A=y SHELL=zsh strace -vfe execve =gdb --args env
execve("/usr/bin/gdb", ["/usr/bin/gdb", "--args", "env"], ["A=y", "SHELL=zsh"]) = 0
[...]
(gdb) run
Starting program: /home/chazelas/env
[...]
[pid 9335] execve("/bin/zsh", ["zsh", "-c", "exec /home/chazelas/env "], ["A=y", "SHELL=zsh", "LINES=52", "COLUMNS=144"]) = 0
[pid 9335] execve("/home/chazelas/env", ["/home/chazelas/env"], ["A=x", "SHELL=zsh", "LINES=52", "COLUMNS=144", "HOME=/home/chazelas", "LOGNAME=chazelas", "SHLVL=0", "PWD=/home/chazelas", "OLDPWD=/home/chazelas", "_=/home/chazelas/env"]) = 0
A=x
[...]
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.
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author