bug-bash
[Top][All Lists]
Advanced

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

Re: "history -s" within PROMPT_COMMAND deletes last history item.


From: Chet Ramey
Subject: Re: "history -s" within PROMPT_COMMAND deletes last history item.
Date: Sat, 22 Oct 2011 22:47:42 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1

On 10/20/11 12:02 PM, lester@vmw-les.eng.vmware.com wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu' 
> -DCONF_VENDOR='unknown' -DLOCALEDIR='/home/lester/base/share/locale' 
> -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -g 
> -O2
> uname output: Linux vmw-les.eng.vmware.com 2.6.40.6-0.fc15.x86_64 #1 SMP Tue 
> Oct 4 00:39:50 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
> Machine Type: x86_64-unknown-linux-gnu
> 
> Bash Version: 4.2
> Patch Level: 10
> Release Status: release
> 
> Description:
>       The "history -s" usually removes the last history item which
>       is usually the "history -s" command itself, but PROMPT_COMMAND
>       disables history and causes an unrelated command to be deleted.
> 
> Repeat-By:
>       $ history -s '# line 1' ; history -s '# line 2' ; history 2
>       X1 # line 1
>       X2 # line 2
>       $ PROMPT_COMMAND="history -s '# line 3' ; history -s '# line 4'"
>       $ history 5
>       X1 # old command
>       X2 # line 1
>       X3 # line 2
>       X4 # line 3
>       X5 # line 4
>       
>       Expect:
>       X1 # line 1
>       X2 # line 2
>       X3 PROMPT_COMMAND="history -s '# line 3' ; history -s '# line 4'"
>       X4 # line 3
>       X5 # line 4
>       
>       No new commands will enter history as they are replaced with $'# line 
> 3\n# line 4'

Thanks for the report.  This will be fixed in the next release of bash.
Here's a patch you can test for proper behavior.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/

Attachment: history-delete-histent.patch
Description: Text Data


reply via email to

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