If I examine my bash shell in an OS X (10.6.4) terminal, such as by typing
echo $0, there is a dash in front of my shell, like this:
-bash. What does this dash mean?
It means that
bash is invoked as a login shell.
man bash says:
A login shell is one whose first character of argument zero is a
-, or one started with the
When bash is invoked as an interactive login shell, or as a non-interactive shell with the
--loginoption, it first reads and executes commands from the file
/etc/profile, if that file exists. After reading that file, it looks for
~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The
--noprofileoption may be used when the shell is started to inhibit this behavior.
When a login shell exits, bash reads and executes commands from the file
~/.bash_logout, if it exists.
login -pf in your
ps output, which starts a login shell by default.
login -pf and
login -pfl and see the difference.
man login describes the difference:
-lTells the program executed by login that this is not a login session (by convention, a login session is signalled to the program with a hyphen as the first character of
argv; this option disables that), and prevents it from
chdir(2)ing to the user's home directory. The default is to add the hyphen (this is a login session).