8

First login process name seems to be set to -bash, but if I subshell then it becomes bash. for example:

root@nowere:~# echo $0
-bash
root@nowere:~# bash
root@nowere:~# echo $0
bash

-bash is causing some scripts to fail, such as . /usr/share/debconf/confmodule

exec /usr/share/debconf/frontend -bash
Can't exec "-bash": No such file or directory at /usr/share/perl/5.14/IPC/Open3.pm line 186.
open2: exec of -bash failed at /usr/share/perl5/Debconf/ConfModule.pm line 59

Anyone know the reason why $0 is set to -bash?

Volker Siegel
  • 12,820
  • 5
  • 48
  • 65
James Shimer
  • 83
  • 1
  • 3

1 Answers1

6

If the output of echo $0 command is -bash it means that bash was invoked as a login shell. man bash says somewhere at line 126:

A  login shell is one whose first character of argument zero is a -, or 
one started with the --login option.

See more about here: Difference between Login Shell and Non-Login Shell.

So your shell is still /bin/bash (this can be checked with echo $SHELL command) and I suggest you to use that command which give you error as normally:

exec /usr/share/debconf/frontend bash
Radu Rădeanu
  • 166,822
  • 48
  • 327
  • 400
  • Thanks, it does appears that login is correctly adding the "-" to the login shell process name. That answers my question. – James Shimer Oct 30 '13 at 17:05