WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: $PATH exports saved on purpose?  (Read 1810 times)

Offline PDP-8

  • Hero Member
  • *****
  • Posts: 915
$PATH exports saved on purpose?
« on: December 16, 2019, 05:40:46 PM »
I noticed that temporary changes to the $PATH variable by merely exporting them in the shell, will be saved on logout/login, or reboot.  Is that normal?

I was playing around with putting my pwd at the end of the path, merely by exporting it from the commandline:

Code: [Select]
export PATH=$PATH:.
Ok, works fine.  ENV displays it at the end, and I can run stuff from my pwd if I like.

So I put it into my .ashrc file at the end, and reboot, rather than manually exporting it.

Now, ENV or echo $PATH reveals multiple additions to the end of the pathline referencing my pwd twice.

Code: [Select]
PATH=/home/tc/.local/bin:/usr/local/sbin:/usr/local/bin:apps/bin:/sbin:/usr/bin:/sbin:/bin:/etc/sysconfig/tcedir/ondemand/.:.
Notice the .:. double reference?

That will only occur when I test out the path variable first, and then if I like it, decide to make it permanent in .ashrc and reboot.

It just makes me wonder why the system seems to be saving temporary path export variables upon reboot, when it should only be saving permanent changes in config files, like .ashrc?

Update: this only seems to be happening when using the pwd, not other fully-qualified paths.

« Last Edit: December 16, 2019, 06:02:17 PM by PDP-8 »
That's a UNIX book! - cool  -- Garth

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10960
Re: $PATH exports saved on purpose?
« Reply #1 on: December 17, 2019, 01:16:00 AM »
Maybe it's added twice? First when you log in, second when you open a new shell, inheriting the login environment. "export PATH=$PATH:whatever" adds whatever to the current PATH, and executing it many times would add it many times.
The only barriers that can stop you are the ones you create yourself.

Offline PDP-8

  • Hero Member
  • *****
  • Posts: 915
Re: $PATH exports saved on purpose?
« Reply #2 on: December 17, 2019, 03:33:34 AM »
Yep - it is as if the .ashrc is being processed twice, putting my path append in twice at the end.  I'm running 10.1 with the minimal xvbdev desktop.

More testing reveals that this seems to be .ashrc based, and not an issue with exporting from the commandline - not related.  AND I was hasty - it happens with any PATH addition, not just pwd.

Maybe you can duplicate?  Add this to your .ashrc

Code: [Select]
export PATH=$PATH:/funky
Now simply logout and log back in, and do an ENV or echo $PATH and take a look.

At the end of my path I've got
:/funky:/funky

Not a showstopper, but interesting.  Being a multiple, I tried turning off my multivt kernel option, and ran with the text kernel option too just to see if the minimal desktop was causing .ashrc to be read twice.  Nope, seems like any path addition in .ashrc causes the duplication - at least here.
That's a UNIX book! - cool  -- Garth

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11213
Re: $PATH exports saved on purpose?
« Reply #3 on: December 17, 2019, 07:13:32 AM »
Hi PDP-8
Take a look inside  ~/.profile  for adding paths.

Offline PDP-8

  • Hero Member
  • *****
  • Posts: 915
Re: $PATH exports saved on purpose?
« Reply #4 on: December 17, 2019, 05:36:51 PM »
Roger that - .profile is more appropriate and works fine.

Heh, but just don't tack it on the end of the file in a hurry after the termtype section.  Works great prior to that in the ash/bash environmental section.

I gotta' slow down and think before I edit! :)
That's a UNIX book! - cool  -- Garth

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11213
Re: $PATH exports saved on purpose?
« Reply #5 on: December 17, 2019, 08:04:42 PM »
Hi PDP-8
I ran into the same thing a few months ago:
http://forum.tinycorelinux.net/index.php/topic,13034.msg141138.html#msg141138

Maybe a little note for the unwary would be in order:
Code: [Select]
if [ -f "$HOME/.ashrc" ]; then
   export ENV="$HOME/.ashrc"
   . "$HOME/.ashrc"
fi

#-------- Do not add anything beyond this line. --------#
TERMTYPE=`/usr/bin/tty`
[ ${TERMTYPE:5:3} == "tty" ] && (
[ ! -f /etc/sysconfig/Xserver ] ||
[ -f /etc/sysconfig/text ] ||
[ -e /tmp/.X11-unix/X0 ] ||
startx
)