Le 27/11/2019 à 18:14, Bruce Dubbs a écrit : > On 11/27/19 11:07 AM, Pierre Labastie wrote: >> Le 27/11/2019 à 06:05, Xi Ruoyao a écrit : >>> On 2019-11-26 14:56 -0600, Douglas R. Reno wrote: >>>> On 2019-11-26 14:39, Bruce Dubbs wrote: >>>>> On 11/26/19 1:27 PM, Xi Ruoyao wrote: >>>>>> On 2019-11-26 12:54 -0600, Bruce Dubbs wrote: >>>>>>> On 11/26/19 9:30 AM, Xi Ruoyao wrote: >>>>>>> >>>>>>>> But on Arch (and some other distributions) non-login bash >>>>>>>> loads >>>>>>>> /etc/bash.bashrc before .bashrc. The environments in >>>>>>>> bash.bashrc >>>>>>>> may >>>>>>>> pollute the LFS building environment. For example, on Arch, >>>>>>>> our >>>>>>>> $PS1 >>>>>>>> (set in .bash_profile, should be '\u:\w\$ ') would be >>>>>>>> overwritten >>>>>>>> (become `[\u@\h \W]\$ '). >>>>>>> >>>>>>> With the exception of PS1, is there anything else in >>>>>>> /etc/bash.bashrc >>>>>>> that interferes with the lfs user's environment? We could >>>>>>> easily >>>>>>> fix >>>>>>> the PS1 issue by adding >>>>>>> >>>>>>> PS1='\u:\w\$ ' >>>>>>> >>>>>>> to our .bashrc. >>>>>> >>>>>> On Arch Linux it also sets $PROMPT_COMMAND, and then sources >>>>>> /usr/share/bash_completion/bash_completion (!). >>>>>> >>>>>>> We could also add a note for the user to check the contents of >>>>>>> /etc/bash.bashrc and, if needed, move it out of the way. >>>>>>> >>>>>>> Also, I wonder if using >>>>>>> >>>>>>> exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash -- >>>>>>> rcfile >>>>>>> ~/.bashrc >>>>>>> >>>>>>> would disable sourcing /etc/bash.bashrc. >>>>>> >>>>>> No. I tried that. >>>>>> >>>>>> I found a solution with Google: >>>>>> >>>>>> /home/lfs/.bash_profile: >>>>>> >>>>>> exec env -i ENV=$HOME/.bashrc \ >>>>>> HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash --posix >>>>>> >>>>>> /home/lfs/.bashrc: >>>>>> >>>>>> set +o posix >>>>>> set +h >>>>>> umask 022 >>>>>> # .... (same as LFS book) >>>>>> >>>>>> "--posix" will start POSIX mode and disable rc file >>>>>> loading. Then we >>>>>> use "ENV=$HOME/.bashrc" to tell bash to load our .bashrc >>>>>> file. At >>>>>> last >>>>>> use "set +o posix" in .bashrc to exit POSIX mode. >>>>> >>>>> That looks good. I don't have a system that uses /etc/bash.bashrc >>>>> so >>>>> I can't test it. If you say it works for you, I'll add it. >>> >>> It works for me (at least on Arch). >>> >>>>> -------- >>>>> >>>>> Also, I am running into an issue I haven't noticed before. On my >>>>> existing system if I try to log in as user lfs with .bash_profile >>>>> set, >>>>> it automatically starts bash and then puts it into the background. >>>>> >>>>> # su - lfs >>>>> [1]+ Stopped su - lfs >>>>> # jobs >>>>> [1]+ Stopped su - lfs >>>>> # fg >>>>> su - lfs >>>>> lfs:~$ >>>>> >>>>> The rules in the book work OK as .bash_profile is not present when >>>>> we >>>>> initially change to user lfs and then we source >>>>> .bash_profile. That >>>>> works. >>>>> >>>>> It could have something to do with PAM and su, but I'm not >>>>> sure. Has >>>>> anyone else seen this? >>>>> >>>>> -- Bruce >>>> >>>> Yes I have, it's happening on Debian 10 and on LFS now. I'm not sure >>>> what's causing it >>> >>> I've seen this on LFS. Not sure the reason. >>> >> >> I see this on a fresh install of debian 10, but not on debian unstable, which >> I have installed long ago, but that I update every day. So, it must be some >> config somewhere, that has not been updated on unstable. >> >> Concerning /etc/bash.bashrc on debian: >> it begins with: >> [ -z "$PS1" ] && return >> >> so we could do something like (not tried): >> exec env -i HOME=$HOME TERM=$TERM PS1="" /bin/bash >> >> and then set PS1 in .bashrc > > That may work for debian, but I think it is not generic enough for the book.
You are right: on Arch they use [[ $- = *i* ]] to test whether the shell is interactive... I've tried Xi Ruoyao's solution on debian, and it works. If we do that in the book, I suggest renaming .bashrc to something less generic, so that it is clear we do something non-standard (say .lfs_bashrc, or without the dot, or .lfsrc, or without the dot). Pierre -- http://lists.linuxfromscratch.org/listinfo/lfs-support FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page Do not top post on this list. A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail? http://en.wikipedia.org/wiki/Posting_style
