Reputation: 12634
If in bash I do (from the command line)
echo $0
the output is
bash
and similarly in other shells.
But if I do the same in zsh the output is
-zsh
Why is there that dash in front of zsh?
Upvotes: 8
Views: 1186
Reputation: 531798
An old convention among shells is that if the shell is invoked using a name that starts with -
, it should initialize itself as a login shell. Your terminal emulator is following this convention when it executes zsh
for you.
You can observe this using the -l
flag to zsh
's built-in exec
(which adds a leading -
to the name of the command).
% ( exec bash -c 'echo $0')
bash
% ( exec -l bash -c 'echo $0')
-bash
The effect of the leading -
is generally equivalent to running the shell with the -l
option.
Upvotes: 9