Many of us, customize our shells under Unix (for the difference between Unix and UNIX - see the Art of Unix Programming). We usually add to our PATH environment variable. Usually what we do is
PATH=$PATH:[paths to add]
Lets assume this file is called .profile and is read by the shell on start-up. This approach is good, but if the user were to change our .profile and run
. $HOME/.profile
Then on seeing the PATH variable, it would have repeated path names.
If the change to PATH was
PATH=$PATH:$HOME/bin:.
The on running . $HOME/.profile for the first time the user would see PATH as
[original]:[user's home directory]/bin:.:[user's home directory]/bin:.
One easy way to work around this problem is to use the following approach in your .profile
OLDPATH=${OLDPATH=$PATH}
export OLDPATH
export PATH=
export PATH=$OLDPATH:/sbin:/usr/sbin:$HOME/bin:.
and then customize PATH as the user did previously, repeated running of
. $HOME/.profile shall now not cause the PATH environment variable to grow uncontrollably
Subscribe to:
Post Comments (Atom)
privacy
Some of the policy from the app automation refers to https://rclone.org/privacy/ if you are a general blog reader, follow Google's polic...
-
I received my MS degree from BITS Pilani today. Wow! I am now qualified to do more, I feel so energized. As I am writing this blog, I look ...
-
I reviewed a chapter of Computer Organization & Architecture, Designing for Performance. This is the last of my reviews for a long time ...
-
I still remember meeting a great architect at a place I worked. He was very humble and so good that he was a role model. Basically whether w...
No comments:
Post a Comment