[SLE] How does .bashrc work in KDE (Konsole)
Hi, I have noticed something strange. If I do the following in my .bashrc : export PATH=/mypath:$PATH then I get the following path when I am logged into KDE and using Konsole: /mypath:/mypath:/mypath:rest-of-the-path. If I comment it out in .bashrc I just get: rest-of-the-path. When I do a ctrl-alt-F1 to switch to a console, and log in, it only appears once as expected. Any ideas why this happens. I am using Suse 10.0 btw. Marius -- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
Marius, On Friday 16 June 2006 01:00, Marius Roets wrote:
Hi, I have noticed something strange. If I do the following in my .bashrc
Environment variable manipulation rarely is proper in ".bashrc". You'll also notice under this setup that when you run scripts (that don't include the "--norc" option in their #!/bin/bash shebang line) that another copy of "/mypath" will be prefixed. If you use the "pstree" command and look for your interactive shell (its proces ID is held in the shell variable $$) you'll see it has multiple shell's as parents (and grandparents), and each of them manipulated PATH because of your code in .bashrc. Read the BASH manual ("man bash") for the arcane rules about which set-up scripts are run when. You probably want either .bash_profile or .bash_login for this purpose.
...
Any ideas why this happens.
I am using Suse 10.0 btw.
Marius
Randall Schulz -- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
On Fri, 2006-06-16 at 10:00 +0200, Marius Roets wrote:
Any ideas why this happens. (cut discussion of multiple PATH insertions/runs) I am using Suse 10.0 btw.
It means that the .bashrc is getting run several times, pre-pending the new path to it. Or it could be that the pre-pend has been added in another file that you didn't know about. An easy way to check is to remove the pre-pend from your .bashrc, logout and then log back in to see. I know Red Hat and SuSE different logic for profile, .bashrc, .bash_profile, etc... between user, system, etc... I haven't gotten the entire logic flow down for SuSE, and I'd be very interested if there is a document, FAQ, HOWTO, etc... out there that shows the _entire_logic_ of what and how different system and user files are executed in what order for a bash login shell under SuSE. One thing Red Hat does in its system-wide /etc/bashrc is offer a function called "pathmunge()" to avoid such a scenario, but I don't think that's LSB. I assume SuSE has something similar? Possibly more LSB-compliant? -- Bryan J. Smith Professional, technical annoyance mailto:b.j.smith@ieee.org http://thebs413.blogspot.com ---------------------------------------------------------- The existence of Linux has far more to do with the breakup of AT&T's monopoly than anything Microsoft has ever done. -- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
On 6/16/06, Bryan J. Smith
On Fri, 2006-06-16 at 10:00 +0200, Marius Roets wrote:
Any ideas why this happens. (cut discussion of multiple PATH insertions/runs) I am using Suse 10.0 btw.
It means that the .bashrc is getting run several times, pre-pending the new path to it. Or it could be that the pre-pend has been added in another file that you didn't know about. An easy way to check is to remove the pre-pend from your .bashrc, logout and then log back in to see.
I know Red Hat and SuSE different logic for profile, .bashrc, .bash_profile, etc... between user, system, etc... I haven't gotten the entire logic flow down for SuSE, and I'd be very interested if there is a document, FAQ, HOWTO, etc... out there that shows the _entire_logic_ of what and how different system and user files are executed in what order for a bash login shell under SuSE.
One thing Red Hat does in its system-wide /etc/bashrc is offer a function called "pathmunge()" to avoid such a scenario, but I don't think that's LSB. I assume SuSE has something similar? Possibly more LSB-compliant?
suse-10 too has shell code in /etc/profile which looks like : if test -n "$PROFILEREAD" ; then PATH=/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/java/jdk1.5.0/bin if test "$HOME" != "/" ; then for dir in $HOME/bin/$CPU $HOME/bin ; do test -d $dir && PATH=$dir:$PATH done fi if test "$UID" = 0 ; then test -d /opt/gnome/sbin && PATH=/opt/gnome/sbin:$PATH test -d /opt/kde3/sbin && PATH=/opt/kde3/sbin:$PATH PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH fi for dir in /var/lib/dosemu \ /usr/games \ /opt/bin \ /opt/gnome/bin \ /opt/kde3/bin \ /opt/kde2/bin \ /opt/kde/bin \ /opt/eclipse \ /usr/openwin/bin \ /opt/cross/bin \ do test -d $dir && PATH=$PATH:$dir done unset dir fi add all your paths here in the newline separated entries....and they wont be appended to the $PATH again as $PROFILEREAD will be TRUE -- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
On Fri, 2006-06-16 at 19:26 +0530, Digvijoy Chatterjee wrote:
suse-10 too has shell code in /etc/profile which looks like :
if test -n "$PROFILEREAD" ; then ... code fold ... fi
add all your paths here in the newline separated entries....and they wont be appended to the $PATH again as $PROFILEREAD will be TRUE
Unfortunately, if I read that correctly, that only addresses the issue when /etc/profile is executed. While it will prevent anything _before_ that from being sorted out, anything that executes _afterwards_ (such as user files?) may still do it. In Red Hat, they recommend you always add PATHs with the pathmunge() bash function. It doesn't solve the problem if people don't use pathmunge(), but it gives them a way to add to the PATH without fear of redundant entries. -- Bryan J. Smith Professional, technical annoyance mailto:b.j.smith@ieee.org http://thebs413.blogspot.com ---------------------------------------------------------- The existence of Linux has far more to do with the breakup of AT&T's monopoly than anything Microsoft has ever done. -- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
participants (4)
-
Bryan J. Smith
-
Digvijoy Chatterjee
-
Marius Roets
-
Randall R Schulz