| I misread the man page, and confused myself. It doesn't read .bashrc if you use your login shell.
A login shell reads the first of /etc/profile, ~/.bash_profile or ~/.bash_login. An interactive shell reads ~/.bashrc or the file you override with --rcfile. A non-interactive shell reads none of these.
If you use the default in Terminal, it starts a login shell. If you open a new tab it does the same. This is normal and desirable behavior I think. I have had a .bash_profile and no .bashrc. I would have .bashrc if my evil system administrator was forcing me to use csh for my login shell, and I had a habit of typing "bash" to startup my bash shell.
I think I see what you might be talking about with the different behavior in tabs though. If you add a command to the "Shell" tab in "Settings" in preferences, it doesn't run when you open new tabs, but that's not where you specify your shell... The option to run the command in your shell ("Run in shell") should be a giveaway that this isn't where to specify your unix shell (why would you run your shell in your shell?).
I gather, the Startup tab is for selecting the unix shell that Terminal will launch. The other tab that is confusingly called "Shell", allows you to specify a command to run within your unix shell or wihout your unix shell, e.g. telnet. I suppose any comand you specify here could be considered a shell, .i.e. telnet is a shell for entering telnet commands into, so the name isn't entirely weird.
As a demonstration, I created test.sh:
#!/bin/bash
echo $0
cat > /dev/null
Now with my startup shell selected in Startup (the default, using my login shell). If I have no command entered in the Shell tab, launching a new window and/or a new tab starts my shell as a login shell, .i.e it reads my ~/.bash_profile. Opening a new tab does the same.
Next if I select my test.sh script in "Run command" in the "Shell" tab in "Settings" in preferences, and leave "Run in shell" unchecked, if I open a new window, or launch terminal, it run's my script. When I press Ctrl-D the window closes (because I have "Close if the shell exited cleanly" selected), or I guess it would say "Shell exited" or some such thing. While the window is open, if I open a new tab it opens a unix shell window, and doesn't run my script again in the new tab.
Next if I check "Run in shell" it runs my script in my unix shell, if I open a new window (or launch terminal). If I press Ctrl-D it returns me to my unix shell.
So, I guess use .bash_profile instead of .bashrc, use the default in Startup in preferences and remove any command you have entered in the Shell tab in Settings in Preferences.
Last edited by Cow Loon; November 9th, 2007 at 04:14 PM.
Reason: Obsessive compulsion
|