modifying $PATH


Forum: Other Help Topics
Topic: modifying $PATH
started by: mikshaw

Posted by mikshaw on Sep. 10 2004,19:08
I noticed something unusual in DSL....at least it's unusual from what I've seen in other distros.

I attempted to add a directory to my path so that it is useable from all shells, but it seems that when you startx, the path gets reset.

Normally I'd add this line to ~/.bash_profile:
export PATH="/new/path:$PATH"
and then source ~/.bash_profile and startx.  After that, the new path is available from anything.

However, when I tried this in DSL, it affected only the one shell (tty).  I did startx, and checked my path from an x term, and it didn't show the new path.  I also tried to export the path from the console, and then startx...same thing happend.  It seems like the only way to modify the path is temporarily changing it for a specific shell.  This isn't normal, and it's rather annoying.

Posted by clacker on Sep. 10 2004,22:33
mikshaw, I noticed the same thing when I was trying to add export commands to a bash script and they were gone when the script ended.  I remember reading that that's normal with shell scripts, wether or not it's true with shells as a rule too, I don't know.
Posted by ke4nt1 on Sep. 10 2004,22:49
What happens when you change the .bash_profile in /etc/skel ?

73
ke4nt

Posted by mikshaw on Sep. 10 2004,23:23
Quote (clacker @ Sep. 10 2004,18:33)
mikshaw, I noticed the same thing when I was trying to add export commands to a bash script and they were gone when the script ended.  I remember reading that that's normal with shell scripts, wether or not it's true with shells as a rule too, I don't know.

I'm not sure that's so unusual, depending on the circumstances.  If you have an export command in a script, and the script ends, the variable is removed along with that shell.
If, however, you export from a script, and from that same script you launch an application, the variable will be passed to that application.  It will then disappear when that application closes, unless it passes the variable on to a new application (which will need to be launched from the same string).  It's like a circuit...you can pass the variable as long as the connection is there.  Once you break that circuit, the variable is cut off.

Posted by mikshaw on Sep. 10 2004,23:28
Quote (ke4nt1 @ Sep. 10 2004,18:49)
What happens when you change the .bash_profile in /etc/skel ?

73
ke4nt

I haven't tried that, but as far as I know the contents of /etc/skel are not "in effect"...they're there as a collection of generic files that are copied when a new user is created, but they aren't actually used in daily activities.

edit:  but...i wonder if the files in /home/dsl are created from /etc/skel at boot time.  If this is the case, I could backup /etc/skel/bash_profile and have the path already fixed....hmmm...

edit2: that still doesn't make sense, though.  ~/.bash_profile is a login script which in turn launches X.  If you have a variable exported from that shell, and then start an X session from that shell, the variable should be passed on

Posted by mikshaw on Sep. 11 2004,15:07
<VOICE SRC="homestar">I think I has the solution!</VOICE>
For some reason, /etc/bash.bashrc sources /etc/profile, which in turn resets the PATH variable.
I dunno why it does this, though...it pretty much removes the whole point of having separate login and non-login shells.  /etc/profile is already used when you login, so there's no point in sourcing it for non-login shells as well...it only makes things less versatile.
I could understand doing it the other way around, sourcing bashrc from profile so you can get all settings for a login shell, but the current setup is unnecessary since the settings are already available for child shells.

There is also both /etc/bash.bashrc and /etc/bashrc.  It seems that /etc/bashrc is unused, but I'm not sure of this.

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.