sh prompt

What is the default prompt (PS1) for sh?

Looking at examples of shell scripts it is often shown as '$', but the default (as of 14.0) appears to be '#'.

I've never really paid much attention to prompts, just trying to get a handle on them...
 
sh(1):
Code:
     PS1           The primary prompt string, which defaults to “$ ”, unless
                   you are the superuser, in which case it defaults to “# ”.
 
What is the default prompt (PS1) for sh?
but the default (as of 14.0) appears to be '#'.
As of 14.0, with /bin/sh as default login shell, it's "$" for the root and normal user, not "#".

I have mixed this up somehow. Login shell /bin/sh >14.0 root user "#" , normal user "$".

If the login shell is /bin/csh, default for root user on FreeBSD <14.0, then it's "#" for root and "%" for normal users . See /usr/share/skel dot.* files. All of those dot files are copied in every users home directory by adduser(8) and pw(8) useradd.

/usr/share/skel/dot.cshrc
Rich (BB code):
if ($?prompt) then
    set prompt = "%N@%m:%~ %# "
    set promptchars = "%#"

/usr/share/skel/dot.shrc
Rich (BB code):
# set prompt: ``username@hostname:directory $ ''
PS1="\u@\h:\w \\$ "
 
Back
Top