bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PATCH: Add \? to get PIPESTATUS information in the prompt


From: Chet Ramey
Subject: Re: PATCH: Add \? to get PIPESTATUS information in the prompt
Date: Thu, 6 Sep 2001 11:31:14 -0400

> I wrote:
> > "Wesley J Landaker" <address@hidden> wrote:
> >> This is possible to do, sure, with PROMPT_COMMAND and so forth, but 
> >> it's rather annoying, because running PROMPT_COMMAND actually modifies 
> >> PIPESTATUS, and so forth.
> > 
> > You can save $? befare doing anything else, and restore it at the end.
> 
> Actually, PIPESTATUS is modified by PROMPT_COMMAND, but not by command
> substitution in PS1 (in 2.04, anyway).  $? is modified by both.
> Weird.  Chet, is this something we should rely on, or might it be
> changed?

If you look at parse.y:execute_prompt_command(), it takes pains to
preserve $? around the command's execution.  A trivial test:

PROMPT_COMMAND=false
true
echo $?

echos `0' for me, but I have no command substitutions in my prompt.

Command substitution is supposed to affect $?, according to POSIX.2,
if, after the various word expansions, no command is executed.  I
think it's wrong to have command substitutions in the prompt strings
affect $?, though, so I'm going to change parse.y:decode_prompt_string()
to save and restore $? around the word expansions.

As for PIPESTATUS, I will change things so that it won't change as
the result of executing $PROMPT_COMMAND.

The end result should be that neither $PROMPT_COMMAND nor prompt string
expansion change $? or $PIPESTATUS.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]