I know what is a login shell and the difference between a login shell and a non-login shell.
But what puzzles me is how it is invoked. It is said that a login shell is invoked with a -
as argument 0.
How can we pass an argument to a shell that is being invoked, then argument 0 is the name of the shell itself?
# -bash
-bash: -bash: command not found
Okay nevermind
# bash --login
# echo $0
# bash
I still don't see a -bash
.
Only when I SSH in, then I am able to see a -bash
when issuing echo $0
.
But back to my original question,
- how does Unix/Linux create a login shell ?
- What is the "thing" that creates a login shell during the login process? If it is a "login" process that invokes the bash shell during login, how does it pass argument 0 as
-
to the bash shell?
--login
option?-
as argument 0." This is not generally the case. I guess you read this in theman bash
, but there it is related to the behaviour of theexec
built-in utility. The answer in the link given in the above comment by Mark Plotnick explains it best.