Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 77771 - tcsh: subshells get $PATH reset not inherited
Summary: tcsh: subshells get $PATH reset not inherited
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: Daniel Black (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-12 18:53 UTC by Paul Hirst
Modified: 2010-05-05 15:56 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Hirst 2005-01-12 18:53:59 UTC
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
Comment 1 Daniel Black (RETIRED) gentoo-dev 2005-02-15 02:51:56 UTC
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.
Comment 2 Paul Hirst 2005-02-15 15:47:14 UTC
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.
Comment 3 Poor Yorick 2010-05-05 15:56:46 UTC
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