when PS1='\u:\w\$ ' and user is root, prompt is still $ under bash

Andrea Reina andrea at mandalaspa.com
Thu Jun 8 18:26:54 PDT 2006

> It sounds to me like bash is not recognizing when you run as root.
> Try something like `set | grep UID' from your root shell and confirm that
> both UID and EUID are zero. I'm not sure that's the exact mechanism used
> by bash, but if they are right or wrong might give a clue where to start 
> looking....
> Hope that helps,
> Brandon.

set | grep UID returns 0 for both the UID and EUID. I took a look at the
Bash source -- well, more like I grepped it -- and found these lines
relevant to the substitution starting at line 5490 of y.tab.c:

case '$':
  t = temp = (char *)xmalloc (3);
  if ((promptvars || posixly_correct) && (current_user.euid != 0))
    *t++ = '\\';
  *t++ = current_user.euid == 0 ? '#' : '$';
  *t = '\0';
  goto add_string;

I don't know c (one of the things I want to learn but haven't got
started), but I'm wondering if there's supposed to be the asterisk
before the 't ='? Most of the other case statements (for the other
prompts) don't have the asterisk before the variable.

Walk in peace.
Andrea Reina

More information about the lfs-chat mailing list