On Fri, 4 Aug 2000 11:34:07 -0400, Subba Rao <[EMAIL PROTECTED]> said:
>In BASH, why does the "\u" and "whoami" make a big difference for the
>$? value in PS1 string? The BASH version is 2.04.
Because 'whoami' is a command, and running it resets $?. \u just
looks up the username internally.
Ke
> My PS1 prompt has the following string,
>
> PS1='($?)\u@\h:\w =>'
>
> In this case, when my command fails the BASH variable $? value is displayed
> in my prompt. What is happening is that a command return value stays there
> until an new command is issued.
>
> When I change the PS1 sring to,
On Fri, Aug 04, 2000 at 11:34:07AM -0400, Subba Rao wrote:
>
> PS1='($?)\u@\h:\w =>'
> PS1='($?)`whoami`@\h:\w =>'
> In BASH, why does the "\u" and "whoami" make a big difference for
> the $? value in PS1 string? The BASH version is 2.04.
My assumption is that using whoami with the ` ` causes it
when you change \u to `whoami`, you get the 0 value because you are
executing `whoami` everytime you get a prompt, i think. `whoami` has an
exit code of 0, successful, so that's what goes into $?. \u, \h, \w, \W,
etc aren't executed, they're properties of the shell at that time.
that's the way