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

"Pierre Labastie" ([email protected] via blfs-dev Mailing List) <[email protected]>
Newsgroups gmane.linux.lfs.beyond.devel
Message-ID <[email protected]>
On Wed, 2025-09-24 at 03:04 -0300, Jamenson Espindula wrote:
> Em ter., 23 de set. de 2025 às 23:46, Xi Ruoyao
> <[email protected]> escreveu:
> > 
> > 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
> 
> More context to help understand what I mean.
> 
> I use the GNU Bash, as recommended in the LFS and BLFS books. I
> always
> build the packages manually (only one time I built the LFS system via
> jhalfs). However, I use GNU Screen to copy the build commands from
> the
> books and paste them in the command line (typing all the build
> commands is highly error prone and time consuming).
> 
> That said, I realized that, inside the GNU Screen, neither completion
> of the GNU Bash was working, nor the 'Xorg Build Environment'. The
> completion is not so 'essential', but the 'Xorg Build Environment' is
> highly 'essential' to whoever is going to build the X Window System!
> 
> I am building my new LFS. I have been aware of that all for a long
> time now, but never posted a word about it before. I understand that
> you, LFS Developer Team, deserves to be aware that, inside the GNU
> Screen, neither the completions of the GNU Bash will work nor the
> 'Xorg Build Environment' will be configured (considering the default
> configurations and the stock files).
> 
> I hope that adition helped clear the initial post!

According to "man bash", /etc/profile is only for login shells, and
users may expect this to be true. So adding automated ways to read this
in non-login shells would defeat normal bash expectations. I don't
think the book should propose this.

But of course, users may do what they want: for example, jhalfs is
faced to the same problem, and has "source /etc/profile" in all its
scripts. This has the advantage of immediately updating the environment
when some script changes the content of files in /etc/profiles.d.

There are several solutions for your use case, I think. One is to have
a dedicated user for building packages and have "source /etc/profile"
in its ~/.bashrc, and use another user when you want the normal bash
behavior.

Pierre

-- 
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.