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@myhost:~ =>
(0)subb3@myhost:~ => lssdfh <== This is no command
(258)subb3@myhost:~ =>
(258)subb3@myhost:~ =>
(258)subb3@myhost:~ =>
(258)subb3@myhost:~ => ls
<file listing>
(0)subb3@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@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.
--
Subba Rao
[EMAIL PROTECTED]
http://pws.prserv.net/truemax/
=> Time is relative. Here is a new way to look at time. <=
http://www.smcinnovations.com
_______________________________________________
techtalk mailing list
[EMAIL PROTECTED]
http://www.linux.org.uk/mailman/listinfo/techtalk