In tcsh, when I launch a subshell, the environment of the subshell gets inherited from the parent. However, various environment variables get reset to defaults, eg $PATH. For example: setenv PATH ${PATH}:foo tcsh echo $PATH will not show foo on the end of the subshell's $PATH. However, setenv FOO bar tcsh echo $FOO will echo 'bar' as expected. I think this is due to /etc/csh.cshrc sourcing /etc/csh.env which sets many environment variables including $PATH to default values, irrespective of whether they are allready set. I'm not sure if this is the intended behaviour or not - appologies if so. I'm finding that various bits of software I use rely on being able to add to $PATH and have that propogated into subshells. Interestingly, bash on gentoo *does* propogate changes to $PATH into subshells without resetting them to defaults, as does tcsh on redhat (though I didn't install the latter myself so don't know if this is due to the local setup). Reproducible: Always Steps to Reproduce: 1. setenv PATH ${PATH}:foo 2. tcsh 3. echo $PATH Actual Results: 'foo' not on end of subshells' path Expected Results: 'foo' on end of subshell's path
yes its weird - don't know why. I guess I haven't found an answer yet and I'm sure this is something that could be answered elsewere. To be perfectly honest I'm not interested in looking into this any further. Take it upstream or to a user groups somewhere if your still interested.
Well, after a bit of poking around I can tell you why it happens - because any tcsh that gets launched sources /etc/csh.cshrc, and this file does the following (in order but obviously not complete): source ~/.tcsh.config source /etc/csh.env In /etc/csh.env, we unconditionally setenv various things, including $PATH, to absolute values.
For googlers who come across this bug: Note also that a shell variable called PATH can shadow the environment variable called PATH. for more info, see http://www.ynform.org/w/Pub/Csh