Bash manual says:

A login shell is one whose first character of argument zero is ‘-’, or one invoked with the --login option.

However, I was wonderying why I have the following error?

$ -bash
No command '-bash' found, did you mean:
 Command 'rbash' from package 'bash' (main)
 Command 'bash' from package 'bash' (main)
-bash: command not found

How can we start bash with the first character of argument zero being ‘-’?



With Bash:

exec -a -bash bash

With Zsh:

ARGV0=-bash bash # or ARGV0=-bash exec bash
  • 3
    With the caveat, on the Bash variant, that the current shell is replaced with the new one. And funnily enough Tim already knew the answer to this question. – Stephen Kitt Apr 5 '18 at 12:39
  • Thanks. Why do I have the command not found error? – Tim Apr 5 '18 at 12:48
  • because you don't have a command named -bash. the documentation that you quoted, then bolded mentioned the ARGV0 of the bash process starting with -, not the command name. – llua Apr 5 '18 at 12:54
  • See also unix.stackexchange.com/questions/382984 from 2017. – JdeBP Apr 16 '18 at 4:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.