Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
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 '12 at 17:35
    
Linux 3.2 embedded system. –  E-rich Oct 11 '12 at 17:39

1 Answer 1

up vote 5 down vote accepted

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")

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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