bug-bash
[Top][All Lists]
Advanced

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

Re: FEATURE REQUEST: when storing history, skip failed commands dependin


From: Chet Ramey
Subject: Re: FEATURE REQUEST: when storing history, skip failed commands depending on exit status
Date: Tue, 14 Aug 2007 14:05:20 -0400
User-agent: Thunderbird 2.0.0.6 (Macintosh/20070728)

Roland Eggner wrote:
> $ bash --version
> GNU bash, version 3.1.17(1)-release (i486-pc-linux-gnu)
> 
> Description:
>       FEATURE REQUEST:
>       when storing history, skip failed commands depending on exit status, 
> controlled by a third option "ignorefailed" added to HISTCONTROL

Commands are stored in the history list well before being executed.  If
you would like to remove commands from the history based on exit status,
you are on the right track with testing $? in PROMPT_COMMAND.  Used with
`history -d', you can delete the previous command.  (The previous command
number can be obtained using $(history 1|awk '{print $1}') when
$PROMPT_COMMAND is executed.)

Keep in mind that commands evaluated while expanding $PS1 will change the
value of $?.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                       Live Strong.  No day but today.
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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