In the Terminal preferences, I'm able to configure the Terminal to "Open shells with:" -> "Command (complete path):" /opt/local/bin/bash.

What options is the terminal passing when invoking this command? Terminal appears to run each shell as a login shell, so I'm assuming --login is being passed?

Is there any Apple documentation that gives an overview of exactly what is being run when you open a terminal window?

2 Answers 2


No arguments are passed. The terminal runs login -pfq $USER $PROGRAM, which in turn runs the specified program. login signals to the program that it is a login shell by prepending a - to argv[0] (the program name).

For the default shell, Terminal actually does something different. It invokes login -pfl $USER /bin/bash -c exec -la bash /bin/bash, where the -l option to login tells it not to run the command as login shell, while the -l option to exec tells it to run its argument as a login shell (by adding the dash). The reason while this is done is that login also sets the current directory to the user's home directory when it runs a program as a login shell, while exec doesn't. This allows the Terminal to open shells in the same current directory as the current tab, without login setting it back to the home directory.

  • When I change the terminal preferences to /opt/local/bin/bash, how does login -pfq $USER $PROGRAM change? Just so I understand your first paragraph, do you mean Terminal runs login -pfq cwilson /opt/local/bin/-bash?
    – cdwilson
    Commented Jan 3, 2014 at 2:18
  • No, the terminal runs login -pfq cwilson /opt/local/bin/bash. Then login executes bash, but passes -bash in argv[0].
    – LaC
    Commented Jan 15, 2014 at 8:16

The command:


essentially instructs Terminal.app to load an interactive bash shell (the path for your example is likely the macports version). Initially when you open Terminal it starts a login shell session (in bash). Login shells can read files such as ~/.profile, ~/.bash_profile that setup environment variables for your session, so what is being run is mostly indicative of what is configured within those files.

In general, by default when opening a bash shell from Terminal these things would be run:



Open Files and Ports


More Information:

Official Bash Website

Apple Man Page: bash(1)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .