Re: [S.u.S.E. Linux] Re: Is this a Bash 2 problem?
Hubert Thank you for the reply. I appreciate your concern with the way I went about getting my prompt to work. I think I follow your reasoning except for the "pwd -P". I can't find any reference to the "-P" in regards to pwd. I may have done something correct in my .bash_profile because I do not see the same results as yu show. My running of your test yields the following. VT5 wtopa-SuSE:~$ cp FUNNY sad cp: FUNNY: No such file or directory VT5 wtopa-SuSE:~$ echo $? 1 VT5 wtopa-SuSE:~$ unset PS1 cp FUNNY sad cp: FUNNY: No such file or directory echo $? 1 Sorry about the lack of a prompt, you understand. As I view the above results, I do not see the problem occuring that prompted your concern, or have I mis-understood you? Wayne Subject: [S.u.S.E. Linux] Re: Is this a Bash 2 problem? Date: Wed, Feb 04, 1998 at 06:58:37PM +0100 In reply to: Hubert SuSE-support Quoting Hubert
Hi,
On Wed, 4 Feb 1998, Luis A. Costabile wrote:
On Sun, 1 Feb 1998, Wayne Topa wrote:
If it DID over ride the one in /etc/profile I would not have written the first message in this thread if the first place! My custom prompt in .bash_profile DIDN't work, UNTIL I commented out the PROMPT_COMMAND in /etc/profile. Did you read all the threaded messages???
I don't have all the right answers Wayne, and forgive me, I know there are some people who appreciate help. We're not all as efficient and thorough as you.
Wayne's custom prompt only modified the PS1 variable. This is a dangerous thing because it can fake the return value of commands when the prompt contains a command itself. Let me explain:
---------- session log ------------------------------ Mandelbrot:/home/alex/mantel > unset PROMPT_COMMAND Mandelbrot:/home/alex/mantel > set | grep PS1 PS1='\h:`pwd -P` > ' Mandelbrot:/home/alex/mantel > cp emil otto cp: emil: No such file or directory Mandelbrot:/home/alex/mantel > echo $? 0 Mandelbrot:/home/alex/mantel > unset PS1 cp emil otto cp: emil: No such file or directory echo $? 1 ---------- session log ------------------------------
As long as PS1 is set using the pwd command, EVERY command seems to return a 0 which means ok. But obviously the "cp" did fail, but the following pwd succeeded, so we get the false return value. After unsetting the PS1 variable, things work correctly. This is why we use the PROMPT_COMMAND feature of the shell.
Of course you can remove the PROMPT_COMMAND definition from /etc/profile and define your own PS1 variable if you are used to do so. But you should expect to get wrong results in certain cases. It's certainly better to define your own PROMPT_COMMAND in .bash_profile.
Lou A. Costabile Voice and Fax: [613] 781-7061
Hubert
-- To get out of this list, please send email to majordomo@suse.com with this text in its body: unsubscribe suse-linux-e
.
-- -- Windows95 (noun): 32 bit extensions and a graphical shell for a 16 bit patch to an 8 bit operating system originally coded for a 4 bit microprocessor, written by a 2 bit company, that can't stand 1 bit of competition. -- To get out of this list, please send email to majordomo@suse.com with this text in its body: unsubscribe suse-linux-e
participants (1)
-
wtopa@ix.netcom.com