FS#66338 - [perl] bash profile script doesn't check if $PATH variable contains perl paths
Attached to Project:
Arch Linux
Opened by Jakub Nowak (MrQubo) - Tuesday, 21 April 2020, 14:51 GMT
Last edited by Eli Schwartz (eschwartz) - Monday, 12 October 2020, 13:49 GMT
Opened by Jakub Nowak (MrQubo) - Tuesday, 21 April 2020, 14:51 GMT
Last edited by Eli Schwartz (eschwartz) - Monday, 12 October 2020, 13:49 GMT
|
Details
Description:
The `perlbin.sh` script adds three new paths to the $PATH env variable but it doesn't check if those paths aren't already there. The `perlbin.csh` doesn't check this as well but `perlbin.fish` does. Note that `/etc/profile` from `core/filesystem` (https://git.archlinux.org/svntogit/packages.git/tree/trunk/profile?h=packages/filesystem&id=b436e401c6b2115110b99b679d386b4da2ec192f) does this properly using `appendpath()`. I'm using tmux and the perl paths end up in $PATH twice. |
This task depends upon
Closed by Eli Schwartz (eschwartz)
Monday, 12 October 2020, 13:49 GMT
Reason for closing: Fixed
Additional comments about closing: filesystem 2020.08.30-1
perl 5.32.0-2
The desired functionality is implemented.
Though objections were raised about directly sourcing /etc/profile.d/* no *rationale* has been provided for wishing to do so. It seems like this change works out fine.
Monday, 12 October 2020, 13:49 GMT
Reason for closing: Fixed
Additional comments about closing: filesystem 2020.08.30-1
perl 5.32.0-2
The desired functionality is implemented.
Though objections were raised about directly sourcing /etc/profile.d/* no *rationale* has been provided for wishing to do so. It seems like this change works out fine.
(Actually I modified my own /etc/profile to not unset it at all.)
In the case of perl, this "append_path" function must also be done for the csh version of the script.
So, we need to add it to the csh package too, or have and asymmetrical implementation between csh/sh scripts.
Note: On my desktop, 3 scripts are updating the PATH and could benefit of this function.
I fail to see why it's bad to fix it for sh too (thus making 2 out of 3 fixed), just because it doesn't also fix csh.
I think we should do the same in sh and csh version.
Anyway, updating /etc/profile will not be enough. Each sh scripts will need to be updated to use our internal _append_path function.
I fail to see why we should start to have API in /etc/profile when this could be fixed with few lines.
> I fail to see why we should start to have API in /etc/profile when this could be fixed with few lines.
Because those few lines either need to be copied into every sh script that needs it, or we could have *code reuse* since we already have those lines. Why is this controversial? Either we have code reuse or we don't. Which one should it be?
Again, I prefer avoid API between /etc/profile and scripts in /etc/profile.d, while it makes small code duplication.
I'm sure you are competent enough to understand difference between internal and external API.
If Florian or others profile script maintainers think adding such API help them and is the way to go, I'd change my mind.
The following is identical:
export FOO
FOO=bar
vs:
FOO=bar
export FOO
Edit: may apologies, it does have to do with this ticket
This was never a formally supported use case and I'm not sure why you'd want to do that. Can you provide a compelling rationale for why this is valuable functionality, such that the change should be reverted?
...
FWIW, I do customize my own /etc/profile to not `unset -f append_path` as I consider it useful functionality to reuse in my own ~/.bash_profile
If it isn't unset, it won't prevent you from re-sourcing those files...
I use ksh as my login shell, and with this latest update to the perl package, I now get errors spewed at me about append_path not being found when I log in.
Files under /etc/profile.d/*.sh are supposed to be parsable by any Bourne-compatible shell.
The only .pacnew file I have on my entire system right now is "/etc/pacman.d/mirrorlist.pacnew", so I doubt it.
However, doing some further testing, just logging in with ksh is not a specific the trigger for problem, but my problem is the same as what the other person hit with re-sourcing the files under /etc/profile.d/*.sh. I also do that with my login shell environment.
My use case is that a lot of the machines I have to log into their so broken, ancient, and/or mismanaged that my kornshell environment has to be overly defensive. I have to wipe out and restart the initialization of the environment because what gets set up by clueless admins hacking profiles and borked packages breaking so much stuff when using a shell other than bash. It's cleaner, safer and more portable to wipe out everything and redo it rather than trying work around the chaotic brokenness and mess I encounter.
Aside from the chaos problem, manually sourcing the /etc/profile.d/*.sh files is also helpful in setting up X11 and other windowing environments where you're not always going through the full login process but want to get all the env vars set up before launching utilities and the display manager starts.
If you have rogue shell init scripts somewhere that source them directly, that's on you.