Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the difference between bash and -bash. When I execute echo $0, it returns bash on one machine and -bash on the other machine. What is the difference between them?

share|improve this question

migrated from stackoverflow.com May 22 '13 at 11:44

This question came from our site for professional and enthusiast programmers.

1  
I think it's only a matter of formatting the output. As far as I know, there's no such thing as a -bash shell, but I could be mistaken of course. – John Willemse May 22 '13 at 8:30
1  
$0 is only the name of the command by convention. And another convention is for a login shell to have - in front of its name in $0. If you look at man exec you'll see that you can make $0 be anything you like when you execute bash. – Adrian Pronk May 22 '13 at 8:34
up vote 8 down vote accepted

Processes with a - at the beginning of arg 0 have been run via login, or by exec -l in bash.

share|improve this answer
    
Thanks :) After reading your answer, I did help exec and that reads, If the first argument is '-l', then place a dash in the zeroth arg passed to FILE, as login does. – thefourtheye May 22 '13 at 8:40

You must log in to answer this question.

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