/etc/profile.d/*.sh executed twice
-
- Warlord
- Posts: 622
- Joined: 04 Jan 2014, 04:27
- Distribution: Porteus 5.0 x64 OpenBox
- Location: NZ
- Contact:
/etc/profile.d/*.sh executed twice
In Porteus 3.2.2 64bit, LXDE, login as root,
/etc/profile.d/*.sh scripts sourced at the end of /etc/profile,
appear to be executed twice.
I know it because I amend the $PATH in a /etc/profile.d/myprofile.sh, and then in a fresh terminal echo $PATH displays my amendment twice.
/etc/profile.d/*.sh scripts sourced at the end of /etc/profile,
appear to be executed twice.
I know it because I amend the $PATH in a /etc/profile.d/myprofile.sh, and then in a fresh terminal echo $PATH displays my amendment twice.
-
- Shogun
- Posts: 205
- Joined: 18 Aug 2013, 12:09
- Distribution: Slackware PartedMagic Xubuntu
- Location: The Netherlands
/etc/profile.d/*.sh executed twice
Do you use persistence? If so it might be that you add your change to a PATH that already was changed in your previous session. To veryfy test with an Always Fresh boot.
/etc/profile.d/*.sh executed twice
This happens because both the non-login shell startup script as well as the login shell startup script end up calling all scripts in /etc/profile.d
This is on all desktops.
Code: Select all
guest@porteus:~$ cat .bash_profile
# Use settings from ~/.bashrc
if [ -f ~/.bashrc ]; then
source ~/.bashrc
figuest@porteus:~$ cat .bashrc
# Setup color scheme for list call <brokenman>
alias ll='/bin/ls --color=auto -lF'
alias la='/bin/ls --color=auto -axF'
alias ls='/bin/ls --color=auto -xF'
# Append any additional sh scripts found in /etc/profile.d/:
for y in /etc/profile.d/*.sh ; do [ -x $y ] && . $y; done
unset y
# Setup shell prompt for guest <wread and fanthom>
PS1='\[\033[01;36m\]\u@\h:\[\033[01;32m\]\w\$\[\033[00m\] '
PS2='> '
-
- Shogun
- Posts: 205
- Joined: 18 Aug 2013, 12:09
- Distribution: Slackware PartedMagic Xubuntu
- Location: The Netherlands
/etc/profile.d/*.sh executed twice
Hmm, it is years and years ago that I resolved login/non-login "thing" for my linux installations, and consequently forgot completely about it. [/blush] That solution comes down to sourcing the /etc/profile.d/* scripts in /etc/profile only and only doing the missing settings (e.g.PS1, PS2 and the dircolors) in ~/bashrc.
However for a user-extensible distribution like Porteus that is not a complete solution. Instead the profile.d scripts should cater for possible "cumulative" effects. E.g.:
An empty PATH is highly unlikely. For an environment variable that can be empty the code should be like:
However for a user-extensible distribution like Porteus that is not a complete solution. Instead the profile.d scripts should cater for possible "cumulative" effects. E.g.:
Code: Select all
if ! echo "$PATH" | grep -qE "(^|.*:)mydir(:|$)" ; then
export $PATH="$PATH:mydir"
fi
Code: Select all
if ! echo "$LD_LIBRARY_PATH" | grep -qE "(^|.*:)mydir(:|$)" ; then
export $LD_LIBRARY_PATH="$LD_LIBRARY_PATH${LD_LIBRARY_PATH:+:}mydir"
fi
-
- Warlord
- Posts: 622
- Joined: 04 Jan 2014, 04:27
- Distribution: Porteus 5.0 x64 OpenBox
- Location: NZ
- Contact:
/etc/profile.d/*.sh executed twice
Yes indeed, /etc/profile.d/*.sh are executed both from within /etc/profile AND .bashrc.
I've removed these lines from .bashrc.
That solved it then. Or am I now breaking something else? Both "login" and "interactive" shells source /etc/profile anyway...
I've removed these lines from .bashrc.
Code: Select all
# Append any additional sh scripts found in /etc/profile.d/:
for y in /etc/profile.d/*.sh ; do [ -x $y ] && . $y; done
unset y
-
- Shogun
- Posts: 205
- Joined: 18 Aug 2013, 12:09
- Distribution: Slackware PartedMagic Xubuntu
- Location: The Netherlands
/etc/profile.d/*.sh executed twice
As elaborated upon in section 6.2 "Bash Startup Files" of the Bash Reference Manual (which can be downloaded/read from e.g. https://www.gnu.org/software/bash/manual/bash.html) you may or may not be breaking something.Or am I now breaking something else?
-
- Warlord
- Posts: 622
- Joined: 04 Jan 2014, 04:27
- Distribution: Porteus 5.0 x64 OpenBox
- Location: NZ
- Contact:
/etc/profile.d/*.sh executed twice
The scripts in /etc/profile.d are still invoked twice in Porteus-v5.0rc2. Why, and what's the modern way to avoid it?
-
- Shogun
- Posts: 205
- Joined: 18 Aug 2013, 12:09
- Distribution: Slackware PartedMagic Xubuntu
- Location: The Netherlands
/etc/profile.d/*.sh executed twice
It looks like my remarks from 2017 are still applicable ...
- Blaze
- DEV Team
- Posts: 3884
- Joined: 28 Dec 2010, 11:31
- Distribution: ⟰ Porteus current ☯ all DEs ☯
- Location: ☭ Russian Federation, Lipetsk region, Dankov
- Contact:
/etc/profile.d/*.sh executed twice
rych and burdi01, and now this is fixed in the main tree
Thanks.
Thanks.
Linux 6.6.11-porteus #1 SMP PREEMPT_DYNAMIC Sun Jan 14 12:07:37 MSK 2024 x86_64 Intel(R) Xeon(R) CPU E3-1270 v6 @ 3.80GHz GenuineIntel GNU/Linux
MS-7A12 » [AMD/ATI] Navi 23 [Radeon RX 6600] [1002:73ff] (rev c7) » Vengeance LPX 16GB DDR4 K2 3200MHz C16
MS-7A12 » [AMD/ATI] Navi 23 [Radeon RX 6600] [1002:73ff] (rev c7) » Vengeance LPX 16GB DDR4 K2 3200MHz C16
-
- Warlord
- Posts: 622
- Joined: 04 Jan 2014, 04:27
- Distribution: Porteus 5.0 x64 OpenBox
- Location: NZ
- Contact:
/etc/profile.d/*.sh executed twice
Blaze, thank you. Where can I download the "main tree" and if not I have 2 questions please:
How did you fix this particular issue, which file to edit?
I'd like to finally upgrade from porteus 4. Would you advise to start using 5.0rc2 now as it could take another year to wait for Slackware to go to 15 and porteus to go to 5.0 release?
How did you fix this particular issue, which file to edit?
I'd like to finally upgrade from porteus 4. Would you advise to start using 5.0rc2 now as it could take another year to wait for Slackware to go to 15 and porteus to go to 5.0 release?
- ncmprhnsbl
- DEV Team
- Posts: 3933
- Joined: 20 Mar 2012, 03:42
- Distribution: v5.0-64bit
- Location: australia
- Contact:
/etc/profile.d/*.sh executed twice
same as what you did:
"removed these lines from (home/guest/) .bashrc."
Code: Select all
# Append any additional sh scripts found in /etc/profile.d/:
for y in /etc/profile.d/*.sh ; do [ -x $y ] && . $y; done
unset y
.. well, hopefully it won't be a year.. i think they'll go beta sometime soonish(months?) ..
about rc2: there's been a lot of movement in slackware current since rc2 release(aug 2020), not least python and quite few key packages as well as our script rewrite to pygobject3 is further along ... so .. it's pretty likely an rc3 will be put out before slackware goes final or even beta.. at the moment, i'm watching the slackware current changelog: expecting a mass package rebuild for the latest glibc currently in testing..
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44
- Blaze
- DEV Team
- Posts: 3884
- Joined: 28 Dec 2010, 11:31
- Distribution: ⟰ Porteus current ☯ all DEs ☯
- Location: ☭ Russian Federation, Lipetsk region, Dankov
- Contact:
/etc/profile.d/*.sh executed twice
Yepncmprhnsbl wrote: ↑15 Feb 2021, 09:28same as what you did:
"removed these lines from (home/guest/) .bashrc."
Linux 6.6.11-porteus #1 SMP PREEMPT_DYNAMIC Sun Jan 14 12:07:37 MSK 2024 x86_64 Intel(R) Xeon(R) CPU E3-1270 v6 @ 3.80GHz GenuineIntel GNU/Linux
MS-7A12 » [AMD/ATI] Navi 23 [Radeon RX 6600] [1002:73ff] (rev c7) » Vengeance LPX 16GB DDR4 K2 3200MHz C16
MS-7A12 » [AMD/ATI] Navi 23 [Radeon RX 6600] [1002:73ff] (rev c7) » Vengeance LPX 16GB DDR4 K2 3200MHz C16
/etc/profile.d/*.sh executed twice
Scripts in /etc/profile.d are sourced up to thrice (under Bash), but only in one of these three runs fully:
Following in ~/.bashrc and therefore also ~/.bashprofile sourcing stops after "user.sh", i.e. "vdpau.sh", "vdpau-va-gl.sh", and "xdg.sh" are not sourced by ~/.bashrc and ~/.bashprofile. The reason is a wrong "break 2" instruction in "user.sh", breaking also out from the sourcing "for" loop, so all scripts following after "user.sh" in alphabetical order are not sourced. The break is only triggered if a logged-in user exists, i.e. not in /etc/profile - good for those who want to use freedesktop.org compliant "$XDG_RUNTIME_DIR" (defined in "xdg.sh"). This fragile construction should in general be replaced by a stable architecture. Currently the historical "parallelism" with csh seems to be valued higher - obviously without currently offering (t)csh anywhere in Porteus land (is it really needed?)
Note that "fully" restricts to those scripts / files in /etc/profile.d with "x" attribute set - the affected sourcing routines require it (is this really intended?).
- At login /etc/profile is read with the sourcing
- Also at login ~/.bashprofile is read which sources ~/.bashrc with the sourcing
- Then in any user invoked shell ~/.bashrc is read with the sourcing
Following in ~/.bashrc and therefore also ~/.bashprofile sourcing stops after "user.sh", i.e. "vdpau.sh", "vdpau-va-gl.sh", and "xdg.sh" are not sourced by ~/.bashrc and ~/.bashprofile. The reason is a wrong "break 2" instruction in "user.sh", breaking also out from the sourcing "for" loop, so all scripts following after "user.sh" in alphabetical order are not sourced. The break is only triggered if a logged-in user exists, i.e. not in /etc/profile - good for those who want to use freedesktop.org compliant "$XDG_RUNTIME_DIR" (defined in "xdg.sh"). This fragile construction should in general be replaced by a stable architecture. Currently the historical "parallelism" with csh seems to be valued higher - obviously without currently offering (t)csh anywhere in Porteus land (is it really needed?)
Note that "fully" restricts to those scripts / files in /etc/profile.d with "x" attribute set - the affected sourcing routines require it (is this really intended?).