Re: GNU Bash shell startup files

"Bruce Dubbs" ([email protected] via blfs-dev Mailing List) <[email protected]> Sat, 17 Jan 2026 11:55:20 -0600
Newsgroups gmane.linux.lfs.beyond.devel
Message-ID <[email protected]>
On 1/17/26 12:24 AM, Jamenson Espindula ([email protected] via blfs-dev Mailing List) 
wrote:
> Em sex., 16 de jan. de 2026 às 12:44, Pierre Labastie
> <[email protected]> escreveu:
>>
>> We have ~/.profile for the case when the shell is invoked as "sh" (so-
>> called POSIX mode). In this case, ~/.profile is the only personal file
>> that is read.
>> For the problem with completions, I think you need to manually source
>> /etc/profile when using a non login shell. ~/.profile does not source
>> files in /etc/profile.d anyway...
>>
> After well understanding the sequence Bash sources the files (by
> eliminating all confusion in my mind), I had an idea of (locally, in
> my own scripts) moving from '/etc/profile' to '/etc/bashrc' the
> following piece of code:
> 
>   = = = Transcription begins = = =
> 
> for script in /etc/profile.d/*.sh ; do
>          if [ -r $script ] ; then
>                  . $script
>          fi
> done
> 
> unset script
> 
>   = = = Transcription ends = = =
> 
> '/etc/bashrc' is the _last file sourced_ by Bash, after a successful
> login and after a 'su' without the '--login' option. Furthermore, I
> have included the following piece of code:
> 
>   = = = Transcription begins = = =
> 
> for script in /etc/bash_completion.d/* ; do
>          if [ -r $script ] ; then
>                  . $script
>          fi
> done
> 
> unset script
> 
>   = = = Transcription ends = = =
> 
> That last one is intended to source the completions from Ville Skyttä
> <https://github.com/scop/bash-completion/> (Editor Notes suggestion).
> 
> According to my knowledge, such a configuration works outside the GNU
> Screen (on the TTY) and inside the GNU Screen.
> 
> If that configuration causes any problems with other shells, please let me know.
> 
> I suggest the above changes to the default files of the Beyond Linux
>  From Scratch.

I wouldn't want to run those scripts in a sub-shell. The purpose of the files in
/etc/profile.d is primarily to set environment variables. Those are set with the 
export command and are thus automatically propagated to any sub-shell.

What you are doing is adding extra unneeded work to spawning a sub-shell. It's 
probably not noticeable on most systems, but not needed either.

   -- Bruce

-- 
http://lists.linuxfromscratch.org/sympa/info/blfs-dev
Unsubscribe: See the above information page