| Home
| Calendar
| Mail Lists
| List Archives
| Desktop SIG
| Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings Linux Cafe | Meeting Notes | Linux Links | About BLU |
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. A newline for the shell will still return the
previous $? value. $? value is never reset until a new command is issued.
(0)subb3 at myhost:~ =>
(0)subb3 at myhost:~ => lssdfh <== This is no command
(258)subb3 at myhost:~ =>
(258)subb3 at myhost:~ =>
(258)subb3 at myhost:~ =>
(258)subb3 at myhost:~ => ls
<file listing>
(0)subb3 at myhost:~ =>
When I change the PS1 sring to,
PS1='($?)`whoami`@\h:\w =>'
The return value for $? is immediately displayed in the next prompt.
(0)subb3 at myhost:~ =>
(0)subb3 at myhost:~ => lssdfh
(258)subb3 at myhost:~ =>
(0)subb3 at myhost:~ =>
(0)subb3 at myhost:~ => ls
<file listing>
(0)subb3 at myhost:~ => ls o
ls: o: No such file or directory
(1)subb3 at 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.
--
Subba Rao
subb3 at attglobal.net
http://pws.prserv.net/truemax/
=> Time is relative. Here is a new way to look at time. <=
http://www.smcinnovations.com
-
Subcription/unsubscription/info requests: send e-mail with
"subscribe", "unsubscribe", or "info" on the first line of the
message body to discuss-request at blu.org (Subject line is ignored).