Re: Scripts in the '/etc/profile.d/' directory
| Newsgroups | gmane.linux.lfs.beyond.devel |
|---|---|
| Message-ID | <[email protected]> |
On 9/23/25 9:46 PM, Xi Ruoyao ([email protected] via blfs-dev Mailing List) wrote: > On Tue, 2025-09-23 at 22:41 -0300, Jamenson Espindula wrote: >> Hi all. >> >> = = = Transcription begins = = = >> >> for script in /etc/profile.d/*.sh ; do >> if [ -r $script ] ; then >> . $script >> fi >> done >> >> unset script >> >> = = = Transcription ends = = = >> >> I realized that the piece of code above _is_ loaded when a user logs >> in the system (the 'login shell' reads the '/etc/profile' file). >> >> However, when an user instantiates a 'non login shell' (e.g. GNU >> Screen is run), that piece of code is _not_ loaded and so missing >> essential configurations. > > How can they instantiate a GNU Screen without login first? > > Basically /etc/profile.d/* should only export environment variables and > whenever you start a shell in a login session, it should inherit the > environment variables already exported. If some "essential > configuration" is not an exported environment variable, or the > environment variable shouldn't be inherited (like the GPG_TTY one), it > just shouldn't be in /etc/profile.d (it should be in bashrc instead). > > Yes the approach will fail if the login shell is not bash (I use zsh), > or you somehow start GNU Screen via initscript or systemd unit, but I > think those things are currently completely unsupported by the book. If > you do those you are on your own (like I). I think there are times when using a display manager, ~/.bash_profile is not run, so the /etc/profile.d/ scripts are not run. If that is the case then I think ~/.bashrc does need something like 'if some-condition; then ~/.bash_profile; fi' or whatever the program that does the login needs to run 'bash --login'. You do NOT want .bashrc to run the /etc/profile.d/ scripts every time it is invoked. -- Bruce -- http://lists.linuxfromscratch.org/sympa/info/blfs-dev Unsubscribe: See the above information page