Re: Scripts in the '/etc/profile.d/' directory

"Xi Ruoyao" ([email protected] via blfs-dev Mailing List) <[email protected]>
Newsgroups gmane.linux.lfs.beyond.devel
Message-ID <[email protected]>
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).

-- 
Xi Ruoyao <[email protected]>

-- 
http://lists.linuxfromscratch.org/sympa/info/blfs-dev
Unsubscribe: See the above information page
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.