Interesting $0 Problem

Anton Yuzhaninov citrin+bsd at
Fri Oct 28 03:48:37 UTC 2016

On 10/27/16 22:44, Tim Daneliuk wrote:
> I've used *BSD for decades and this is a new one to me.  I've never seen
> this behavior anywhere else (like Linux).  Do you have some sense of the
> rationale' for this?

It is very old Unix convention - argv[0] for login shells is prefixed by 

 From AT&T UNIX SRV2 (released in April, 1984):

file /src/cmd/login.c

char    minusnam[16] = "-";


/*      Generate the name of the shell with a '-' sign in front of it.  */
/*      This causes .profile processing when a shell is exec'ed.        */

         strcat(minusnam, namep);

More information about the freebsd-questions mailing list