[Top][All Lists]

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

Re: issues in bash found while creating command result display

From: Chet Ramey
Subject: Re: issues in bash found while creating command result display
Date: Mon, 15 Apr 2019 17:31:28 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

On 4/14/19 9:40 PM, Paul Wise wrote:
> On Sun, 2019-04-14 at 17:28 -0400, Chet Ramey wrote:
>> That's the number of positional parameters.
> Oops, I mean the command number variable \# that is available at PS1
> evaluation time but not when PROMPT_COMMAND is run. I was able to
> workaround this by deferring the decision to display the status until
> the PS1 evaluation time and using math functions to access and store
> the command number variable \# to a normal variable.

You can use $HISTCMD with a slight fix that's now in the devel branch.

>> Syntax errors set $? to 2. SIGINT at the prompt sets $? to 130. There's
>> no way to determine whether or not those exit statuses differ from an
>> exit status resulting from a command being run.
> I managed to workaround this with some heuristics but it would be much
> nicer to be able to properly differentiate between these cases.

The Korn shell uses values > 256 to denote `internal' shell exit statuses,
but that violates POSIX.

>> PIPESTATUS doesn't get set until a job completes. $? will be reset to
>> 128+SIGNUM when a job stops, since that is what shells do and it seems
>> reasonable as a way to let the user know a job suspended. It doesn't seem
>> particularly useful to set PIPESTATUS to, e.g., {146, 146, 146} in this
>> case, though.
> Having the former value of PIPESTATUS when $? has been reset doesn't
> seem useful either, I think it would be better to unset PIPESTATUS when
> setting $? but not PIPESTATUS if you aren't going to set PIPESTATUS.

I'll keep that in mind for a future version.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://tiswww.cwru.edu/~chet/

reply via email to

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