Re: GNU Bash shell startup files
"Xi Ruoyao" ([email protected] via blfs-dev Mailing List) <[email protected]> Sat, 17 Jan 2026 17:39:38 +0800
| Newsgroups | gmane.linux.lfs.beyond.devel |
|---|---|
| Message-ID | <[email protected]> |
On Sat, 2026-01-17 at 03:24 -0300, Jamenson Espindula 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. Sourcing /etc/profile.d/* in bashrc is confusing (as *profile*.d means it's for profile). If we decide to reset the environment for each interactive bash shell we'd at least rename the directory to bashrc.d instead. And we'd also need to audit all the scripts in the directory so they don't do stupid things if one is invoked twice (IIRC some of them is doing such a stupid thing like bloating an environment variable with duplicated entries). -- Xi Ruoyao <[email protected]> -- http://lists.linuxfromscratch.org/sympa/info/blfs-dev Unsubscribe: See the above information page