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 Wed, 2025-09-24 at 03:04 -0300, Jamenson Espindula wrote:

> 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 still failed to get why.  Again if you start GNU screen in an
environment with XORG_PREFIX and XORG_CONFIG (or any variable) set, it
should inherit those variables and they should be available inside the
screen session.

Then I took a look at the screen manual and saw:

       In-addition, new windows can be created by running a command like:

              screen emacs prog.c

       from  a  shell  prompt within a previously created window.  This will not
       run another copy of screen, but will instead supply the command name  and
       its  arguments  to  the window manager (specified in the $STY environment
       variable) who will use it to create the new window.   The  above  example
       would start the emacs editor (editing prog.c) and switch to its window. ‐
       Note  that  you  cannot transport environment variables from the invoking
       shell to the application (emacs in this case), because it is forked  from
       the parent screen process, not from the invoking shell.

So the problem is we have things like

export XORG_PREFIX="<PREFIX>"
export XORG_CONFIG="--prefix=$XORG_PREFIX --sysconfdir=/etc \
    --localstatedir=/var --disable-static"

cat > /etc/profile.d/xorg.sh << EOF
XORG_PREFIX="$XORG_PREFIX"
XORG_CONFIG="--prefix=\$XORG_PREFIX --sysconfdir=/etc --
localstatedir=/var --disable-static"
export XORG_PREFIX XORG_CONFIG
EOF
chmod 644 /etc/profile.d/xorg.sh

The export commands make the correct setting for the current session,
and the /etc/profile.d/xorg.sh make it correct for the next login, and
we consider them enough.  But if you spawn another shell with screen or
some desktop terminal emulator *without logout and login again* the
setting will *not* be applied for the new shell.

And there's even a worse case: if you run the instructions for
"Introduction to Xorg-7" in one shell and then attempt to run the
instructions for some Xorg component in another shell you've already
started before you create /etc/profile.d/xorg.sh, we'd have absolutely
no way to sync the new environment setting into that shell unless
manually running "source /etc/profile.d/xorg.sh" there.

I don't know what we should do here.  Perhaps moving the environment
variables needed for building packages into /etc/bashrc.d and make
/etc/bashrc source it, then telling people to source /etc/bashrc in *all
activate interactive shells* whenever /etc/bashrc.d is modified?

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