Difference: MacOSXLoginScripts (1 vs. 8)

Revision 8
05 Jun 2007 - Main.TomRockwell
Line: 1 to 1
 
META TOPICPARENT name="MacOSX"
Note that the info on this page is mainly generic to any \*nix machine and BASH.
Line: 26 to 26
 

What XTerm and Terminal do on MAC

Changed:
<
<
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.
>
>
Terminal gives you an interactive login shell. xterm gives you an interactive non-login shell, remember that if you launch xterm from the command-line, it will be a sub-process of that shell and inherit the environment. xterm -ls gives you an interactive login shell.
 
Changed:
<
<
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).
>
>
X11 Menu When you launch a program from the X11 menu, the process first gets an interactive non-login environment; /etc/bashrc and ~/.bashrc are run. So if you launch xterm this way, the init scripts run are: /etc/bashrc, ~/bashrc, /etc/bashrc, ~/.bashrc.
 

A Way to See Which Scripts Run...

Revision 7
05 Jun 2007 - Main.TomRockwell
Line: 1 to 1
 
META TOPICPARENT name="MacOSX"
Note that the info on this page is mainly generic to any \*nix machine and BASH.
Line: 35 to 35
  I added code like this to /etc/profile /etc/bashrc ~/.profile and ~/.bashrc to show how these scripts run:
Changed:
<
<
# init script execution record vars... # 1 => /etc/bashrc # 2 => /etc/profile # 4 => ~/.bashrc # 8 => ~/.profile let "INITHIST = INITHIST | 0" export INITHIST_ETC_PROFILE=$INITHIST let "INITHIST = INITHIST | 2" export INITHIST
>
>
# init script execution record var... export INITHIST="${INITHIST}__PROFILE_"`date "+%H:%M:%S"`"__"
 

-- TomRockwell - 01 Jun 2007
Revision 6
05 Jun 2007 - Main.TomRockwell
Line: 1 to 1
 
META TOPICPARENT name="MacOSX"
Note that the info on this page is mainly generic to any \*nix machine and BASH.
Line: 30 to 30
 

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).
Added:
>
>

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 vars...
# 1 => /etc/bashrc
# 2 => /etc/profile
# 4 => ~/.bashrc
# 8 => ~/.profile
let "INITHIST = INITHIST | 0"
export INITHIST_ETC_PROFILE=$INITHIST
let "INITHIST = INITHIST | 2"
export INITHIST
  -- TomRockwell - 01 Jun 2007

META FILEATTACHMENT attachment="bash-invocation.txt" attr="" comment="Section of BASH man page" date="1180731410" name="bash-invocation.txt" path="bash-invocation.txt" size="4757" stream="bash-invocation.txt" user="Main.TomRockwell" version="0"
Revision 5
04 Jun 2007 - Main.TomRockwell
Line: 1 to 1
 
META TOPICPARENT name="MacOSX"
Added:
>
>
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).
Line: 14 to 16
 

Interactive Login Shell
Changed:
<
<
  • The system /etc/profile is run. On many systems this script invokes /etc/bashrc Note that BASH itself doesn't invoke /etc/bashrc.
>
>
  • 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
Added:
>
>
  • 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.
Added:
>
>
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).
  -- TomRockwell - 01 Jun 2007

META FILEATTACHMENT attachment="bash-invocation.txt" attr="" comment="Section of BASH man page" date="1180731410" name="bash-invocation.txt" path="bash-invocation.txt" size="4757" stream="bash-invocation.txt" user="Main.TomRockwell" version="0"
Revision 4
01 Jun 2007 - Main.TomRockwell
Line: 1 to 1
 
META TOPICPARENT name="MacOSX"

What is run when BASH starts

See the Invocation section of man bash for a description of BASH's behaviour (attached below).
Changed:
<
<
Bash may be started in 3 ways:

1 Interactive Login
2 Interactive Non-login
3 Non-interactive Non-login
>
>
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.
Changed:
<
<
Login sessions are invoked by
>
>
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.
  • The first and only the first found of ~/.bash_profile, ~/.bash_login, or ~/.profile is run.

Interactive Non-login shell

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

What XTerm and Terminal do on MAC

 
Changed:
<
<
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...).
>
>
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.
 

-- TomRockwell - 01 Jun 2007
Revision 3
01 Jun 2007 - Main.TomRockwell
Line: 1 to 1
 
META TOPICPARENT name="MacOSX"

What is run when BASH starts

See the Invocation section of man bash for a description of BASH's behaviour (attached below).
Added:
>
>
Bash may be started in 3 ways:
 
Added:
>
>
1 Interactive Login
2 Interactive Non-login
3 Non-interactive Non-login

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

Login sessions are invoked by

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...).
 

-- TomRockwell - 01 Jun 2007
Added:
>
>
 
META FILEATTACHMENT attachment="bash-invocation.txt" attr="" comment="Section of BASH man page" date="1180731410" name="bash-invocation.txt" path="bash-invocation.txt" size="4757" stream="bash-invocation.txt" user="Main.TomRockwell" version="0"
Revision 2
01 Jun 2007 - Main.TomRockwell
Line: 1 to 1
 
META TOPICPARENT name="MacOSX"

What is run when BASH starts

Line: 7 to 7
 

-- TomRockwell - 01 Jun 2007 \ No newline at end of file
Added:
>
>
META FILEATTACHMENT attachment="bash-invocation.txt" attr="" comment="Section of BASH man page" date="1180731410" name="bash-invocation.txt" path="bash-invocation.txt" size="4757" stream="bash-invocation.txt" user="Main.TomRockwell" version="0"
 
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