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.

When I log into a server running SunOS 5.10, my prompt initially is "-bash-3.2$"

Then when I run the following commands, I can see that the prompt is slightly different after typing bash (it no longer begins with a dash), yet echo $SHELL gives the same result.

-bash-3.2$ echo $SHELL
/bin/bash
-bash-3.2$ bash
bash-3.2$ echo $SHELL
/bin/bash

What does this mean, and what implications does it have?

share|improve this question
    
What is the output of 'echo $PS1' ? –  schaiba Jan 27 '13 at 20:43
    
What are the contents of /etc/profile, /etc/bashrc, ~/.bashrc and ~./bash_profile. Also, as glenn already pointed the difference between login and nonlogin shells, can you try running bash --login? –  njsg Jan 27 '13 at 20:59
    
Try echo $0 instead of echo $SHELL –  glenn jackman Jan 27 '13 at 21:07
add comment

2 Answers 2

up vote 4 down vote accepted

PS1 default value under bash is \s-\v\$

  • \s is replaced by the name of your shell ($0)
  • \v is the bash version

The leading - is just due to the first shell being a login shell. This dash is used to differentiate login shells from other ones. The second shell is not a login shell so hasn't that prefix.

PS1 stays like this in your case because none of the scripts sourced at startup override it.

There is no implication about these prompts.

By the way, this OS is more commonly referred to as "Solaris 10" than "SunOS 5.10".

share|improve this answer
    
Heh, fun thing is that uname will actuall show SunOS rather than Sparc, even if /etc/*release has OpenSolaris :-) –  njsg Jan 27 '13 at 21:13
    
@njsg SunOS rather than SPARC ??? –  jlliagre Jan 27 '13 at 21:14
    
s/Sparc/Solaris/. Sigh. –  njsg Jan 27 '13 at 21:20
1  
@njsg That's the expected behavior. In your case SunOS 5.11 is the kernel while (Open)Solaris is the whole OS. Just like say Linux 2.6.32-46 is a kernel and Debian 6.0.6 is a distribution using it. –  jlliagre Jan 27 '13 at 21:25
add comment

The bash manual explains it in the Invoking Bash section:

A login shell is one whose first character of argument zero is ‘-’, or one invoked with the --login option.

Login shells invoke different startup files.

share|improve this answer
    
Yes, this may be what causes the behaviour, but without actually asking the OP for the content of these init files or to start bash with --login, you can't really say this is an answer. –  njsg Jan 27 '13 at 20:58
    
@njsg What Glen is saying is that login(1m) starts a login shell by prepending its argv[0] with a "-". That's the standard way to start a login shell (--login is not). That explains why the name of the shell as reported by PS1 starts with "-". –  Stéphane Chazelas Jan 27 '13 at 22:59
    
Yeah, maybe he should include the part where he explains how that affects a shell with these values of PS1 that were listed above. –  njsg Jan 27 '13 at 23:05
    
I couldn't find any reference in my ubuntu login(1) man page. –  glenn jackman Jan 27 '13 at 23:38
add comment

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.