Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] BASH command return value


> When I change the PS1 sring to,
> 
> PS1='($?)`whoami`@\h:\w =>'
> 
> The return value for $? is immediately displayed in the next prompt. 
> 
> (0)subb3@myhost:~ =>
> (0)subb3@myhost:~ => lssdfh
> (258)subb3@myhost:~ => 
> (0)subb3@myhost:~ => 
> (0)subb3@myhost:~ => ls
>      <file listing> 
> (0)subb3@myhost:~ => ls o
> ls: o: No such file or directory
> (1)subb3@myhost:~ => 
> 
> 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 you are running a whoami command inside the prompt? To convince yourself
that the next number displayed is the result of the command inside the `s,
substitute exit 123 for whoami.

------------------------------------------------------
This mail sent via NLC WebMail: http://www.nlc.net.au/