You are here: Foswiki>Computing Web>MacOSX>MacOSXLoginScripts (revision 7)EditAttach
Note that the info on this page is mainly generic to any \*nix machine and BASH.

What is run when BASH starts

See the Invocation section of man bash for a description of BASH's behaviour (attached below).

Login sessions are started by invoking BASH with the --login option or with the first option starting with -

Interactive is whenever you start BASH to get to a command prompt.

Non-interactive is when you run a bash script, with this invocation, the bashrc and profile login scripts are not rerun (there is a way to get an initialization script run in this instance, but that is a specialized use that I've never seen used...). You can create a non-interactive login shell by giving the proper options to BASH, though I don't see why you would want to.

(For the exact details of the above see the man page).

Interactive Login Shell

  • The system /etc/profile is run. On many systems this script invokes /etc/bashrc Note that BASH itself doesn't invoke /etc/bashrc for login shells.
  • The first and only the first found of ~/.bash_profile, ~/.bash_login, or ~/.profile is run.

Interactive Non-login shell

  • The system /etc/bashrc is run.
  • The user's ~/.bashrc is run.

What XTerm and Terminal do on MAC

xterm produces an Interactive Non-login shell. xterm -ls produces an interactive login shell. Terminal gives you an interactive login shell. These follow the rules above.

When you login to a machine with ssh, you get an interactive login shell. However, if you use ssh to just run a command remotely, an interactive non-login shell is used (just bashrc scripts are run).

A Way to See Which Scripts Run...

I added code like this to /etc/profile /etc/bashrc ~/.profile and ~/.bashrc to show how these scripts run:

# init script execution record var...
export INITHIST="${INITHIST}__PROFILE_"`date "+%H:%M:%S"`"__"

-- TomRockwell - 01 Jun 2007
Topic attachments
I Attachment Action Size Date Who Comment
bash-invocation.txttxt bash-invocation.txt manage 4.6 K 01 Jun 2007 - 20:56 TomRockwell Section of BASH man page
Edit | Attach | Print version | History: r8 < r7 < r6 < r5 | Backlinks | View wiki text | Edit WikiText | More topic actions...
Topic revision: r7 - 05 Jun 2007, TomRockwell
 

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback