From owner-freebsd-ports@FreeBSD.ORG Wed Sep 24 03:32:53 2008 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3E352106564A for ; Wed, 24 Sep 2008 03:32:53 +0000 (UTC) (envelope-from jdc@koitsu.dyndns.org) Received: from QMTA03.emeryville.ca.mail.comcast.net (qmta03.emeryville.ca.mail.comcast.net [76.96.30.32]) by mx1.freebsd.org (Postfix) with ESMTP id 1F4658FC15 for ; Wed, 24 Sep 2008 03:32:52 +0000 (UTC) (envelope-from jdc@koitsu.dyndns.org) Received: from OMTA13.emeryville.ca.mail.comcast.net ([76.96.30.52]) by QMTA03.emeryville.ca.mail.comcast.net with comcast id JQHp1a00517UAYkA3TYsUP; Wed, 24 Sep 2008 03:32:52 +0000 Received: from koitsu.dyndns.org ([67.180.253.227]) by OMTA13.emeryville.ca.mail.comcast.net with comcast id JTYq1a00Q4v8bD78ZTYrQF; Wed, 24 Sep 2008 03:32:51 +0000 X-Authority-Analysis: v=1.0 c=1 a=JdViZEfnDJgA:10 a=2X2Dv3S5izkA:10 a=QycZ5dHgAAAA:8 a=XiYJHFVnlEjS440IxFMA:9 a=HwWQ5ZFXL0OAS8QcauzBffrTBXcA:4 a=EoioJ0NPDVgA:10 a=LY0hPdMaydYA:10 Received: by icarus.home.lan (Postfix, from userid 1000) id A234F17B81A; Tue, 23 Sep 2008 20:32:50 -0700 (PDT) Date: Tue, 23 Sep 2008 20:32:50 -0700 From: Jeremy Chadwick To: Jo Rhett Message-ID: <20080924033250.GA71319@icarus.home.lan> References: <20080921215255.GA9622@icarus.home.lan> <34CFC7BB-E7D2-4B34-9D85-70F4C8E718E2@netconsonance.com> <20080922002229.GA12314@icarus.home.lan> <47824C4F-78DE-41EB-A8C4-D0F7282803D0@netconsonance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <47824C4F-78DE-41EB-A8C4-D0F7282803D0@netconsonance.com> User-Agent: Mutt/1.5.18 (2008-05-17) Cc: freebsd-ports@FreeBSD.org Subject: Re: Incorrect commandline history with bash X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Sep 2008 03:32:53 -0000 On Tue, Sep 23, 2008 at 11:45:07AM -0700, Jo Rhett wrote: > On Sep 21, 2008, at 5:22 PM, Jeremy Chadwick wrote: >> Everyone lecturing me needs to read, slowly, the INVOCATION part of >> the >> bash man page. The method I described above should become apparent >> afterwards. > > I'm sorry if you feel I'm lecturing you -- I'm not. I was just trying > to note that what you said seems to be backwards in my experience. > Moreover, the section of the man page you quoted backed up my analysis: > >> When bash is invoked as an interactive login shell, or as a non- >> interactive shell with the --login option, it >> first reads and executes commands from the file /etc/profile, >> if that file exists. After reading that file, it >> looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in >> that order, and reads and executes commands from >> the first one that exists and is readable. The --noprofile >> option may be used when the shell is started to >> inhibit this behavior. > > It does not read ~/.bashrc. I have tested this and confirmed its > behavior. > > Now, I will go farther and mention the obvious: > >> When an interactive shell that is not a login shell is >> started, bash reads and executes commands from >> ~/.bashrc, if that file exists. > > However, this file is only read when and if you type "bash" after you > are already logged into the system in question. > > In general, because of the way bash works, it would suggest that putting > variables you always want set in the .bashrc is correct, and sourcing it > from .bash_profile is also correct. Variables (like terminal settings) > which are only applied during login should be set in .bash_profile. > Sourcing .bash_profile from .bashrc means you'd need some heft if/then > code to avoid playing havoc with your terminal settings. > > IMHO of course. Thanks Jo. It looks like in my case I do have my "files backwards" (for lack of better phrasing), though I'm well aware of the difference between a login and non-login interactive shell. :-) I don't do any "terminal tweaking" in any of my dotfiles (I rely solely upon what PuTTY or SSH exports to the remote sshd via TERM). Switching the logic I have (.bashrc containing what my old .bash_profile did, and having .bash_profile source .bashrc) continues to work, as documented. -- | Jeremy Chadwick jdc at parodius.com | | Parodius Networking http://www.parodius.com/ | | UNIX Systems Administrator Mountain View, CA, USA | | Making life hard for others since 1977. PGP: 4BD6C0CB |