Path: utzoo!telly!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!BBN.COM!jjd From: jjd@BBN.COM (James J Dempsey) Newsgroups: gnu.bash.bug Subject: Re: Init files (was Questions/bugs.) Message-ID: <8906201402.AA03578@life.ai.mit.edu> Date: 20 Jun 89 14:02:58 GMT References: <8906200300.AA00751@aurel.caltech.edu> Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 64 Brian Fox writes: >> ~/.bashrc is sourced in all interactive shells. Presumably, subshells, >> those created with "( command )", or "shell-script", have already had >> ~/.bashrc sourced at a higher level. >> >> Just what is the order supposed to be (I can read the source, but >> I'm looking for the design rationale for init file invocation). >> >> ~/.bash_profile is sourced for each login shell. ~/.bashrc is sourced >> for each interactive shell. If you wish to have the same commands >> executed for both login and interactive startups, then explicitly >> "source ~/.bashrc" in your ~/.bash_profile. This allows you to *not* >> have the same commadn executed for both login and interactive startups. I would agree with this except for xterm windows and rsh commands. When an xterm window gets started up or when you use rsh to execute a command on a remote host, .bashrc gets executed. In particular, I often use rsh to start up xterm on a remote host. This means that I set things like PATH, PS1, aliases and functions in my .bashrc. Naturally, I want my PATH and the other things set in my login shell too, so there is no way I can avoid sourcing my .bashrc from .bash_profile. I think the basic problem is in what Brian says above: "~/.bashrc is sourced in all interactive shells." Perhaps this should be true, but it isn't. .bashrc isn't sourced in interactive shells which are login shells. It is sourced by rsh commands which aren't interactive. Having said this, I think there should also be some way of determining from inside .bashrc whether or not a given session is interactive or not. Consider again the example above of starting an xterm from an rsh. Both the rsh on the remote host and the xterm will source .bashrc. However, the rsh is not connected to a terminal (and is not interactive) while the xterm is. This means that the in the xterm session I want to use stty to set up things like erase and kill characters and tty driver type (newcrt) while I don't really want to do this in the rsh session. Unfortunately, I can't differentiate between the two inside .bashrc. I can think of three different classes of commands I would want to execute on startup. Class example commands -------------------------------- Always set PATH Login only set terminal type, login information programs Interactive functions, aliases, stty, most environment vars,shell vars The "Always" commands should be done by all shells, whether login, interactive, non-interactive or whatever. The "Login only" commands should only be executed by a login shell as .bash_profile is now. The "interactive" commands should be executed in any shell where the user will be typing commands. There should either be a separate init file for each of these classes or some way to determine which class of shell you are from inside a single init file, or some combination. I apologize for this message getting so long. --Jim Dempsey-- BBN Communications jjd@bbn.com (ARPA Internet) ..!{decvax, harvard, wjh12, linus}!bbn!jjd