Re: Bash login shells with X11 (executing .bash_profile, .bashrc)
Re: Bash login shells with X11 (executing .bash_profile, .bashrc)
- Subject: Re: Bash login shells with X11 (executing .bash_profile, .bashrc)
- From: Sean Ahern <email@hidden>
- Date: Mon, 10 Feb 2003 11:40:49 -0800
Randy Ford wrote:
> I also have a guard variable in my .profile to ensure that code that does
> things like add to the current path does not get executed more than once.
> It slows things down and can lead to other errors if the PATH or MANPATH
> keep getting appended. They will only be altered in my case if my guard
> variable has not been set. However, if I invoke xterm as a logging
> shell, it invokes /etc/profile, which resets the path. Then, when my
> .profile is invoked, the path doesn't get fixed because my guard variable
> is still set. However, my MANPATH variable is not reset by /etc/profile,
> so it does is correct. If I don't use the guard variable, the MANPATH
> (and other things) will repeatedly be altered.
I know this doesn't address the issue, but I have a tiny bit of shell code
which strips out duplicates from my path. I sometimes put this at the end
of whatever dot file I'm messing with. It can easily be modified to
process other environment variables.
This is written in zsh. Translate for whatever shell you're using:
# Process duplicates out of the path. Inefficient, but it works.
# Put "." on the end afterwards.
newpath=()
foreach sub ($path) {
found=0
for new ($newpath) {
if ( [[ $new = $sub ]] ) {
found=1
}
if ( [[ $sub = "." ]] ) { # Get rid of "."
found=1
}
}
if ( [[ $found = 0 ]] ) {
set -A newpath $newpath $sub
}
}
set -A path $newpath . # Put "." back on end
-Sean
__
email@hidden
_______________________________________________
x11-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/x11-users
X11 for Mac OS X FAQ: http://developer.apple.com/qa/qa2001/qa1232.html
Report issues, request features, feedback: http://developer.apple.com/bugreporter
Do not post admin requests to the list. They will be ignored.