6

I have a an inittab file with the following entry:

console::askfirst:-/bin/ash

According to this Man page a '+' character in the process field means

init will not do utmp and wtmp accounting for that process.

However, it does not say anything about a '-' character. What does having the '-' character in the process field do?

2
  • Could it mean that it starts it as a login shell (i.e. execl("/bin/ash","-ash",(char*)NULL))? What OS (or linux distro) are you on?
    – Random832
    Oct 11, 2012 at 17:35
  • Linux 3.2 embedded system.
    – E-rich
    Oct 11, 2012 at 17:39

1 Answer 1

6

The hyphen appears to be a Busybox-specific feature (as is "askfirst", which was how I found that you are using Busybox). The example inittab file says:

# /bin/sh invocations on selected ttys
#
# Note below that we prefix the shell commands with a "-" to indicate to the
# shell that it is supposed to be a login shell.  Normally this is handled by
# login, but since we are bypassing login in this case, BusyBox lets you do
# this yourself...
#
# Start an "askfirst" shell on the console (whatever that may be)
::askfirst:-/bin/sh

So, it starts the shell as a login shell (by beginning argv[0] with a hyphen). What a login shell means is beyond the scope of this question, but it generally at least means it will execute different startup files (i.e. ~/.profile).

The convention of using a hyphen in argv[0], rather than a proper command line flag, to tell the shell it is a login shell, is an ancient convention - it dates back to at least Second Edition UNIX. (argv[0] was simply "-" for login shells until Sixth Edition, then it was changed to "-/bin/sh")

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .