On 10/20/11 12:02 PM, les...@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    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.2-patched/builtins/history.def	2009-01-04 14:32:22.000000000 -0500
--- builtins/history.def	2011-10-22 22:43:11.000000000 -0400
***************
*** 325,331 ****
       history, change #if 0 to #if 1 below. */
  #if 0
!   if (hist_last_line_pushed == 0 && hist_last_line_added && bash_delete_last_history () == 0)
  #else
!   if (hist_last_line_pushed == 0 &&
  	(hist_last_line_added ||
  	  (current_command_line_count > 0 && current_command_first_line_saved && command_oriented_history))
--- 325,332 ----
       history, change #if 0 to #if 1 below. */
  #if 0
!   if (remember_on_history && hist_last_line_pushed == 0 &&
! 	hist_last_line_added && bash_delete_last_history () == 0)
  #else
!   if (remember_on_history && hist_last_line_pushed == 0 &&
  	(hist_last_line_added ||
  	  (current_command_line_count > 0 && current_command_first_line_saved && command_oriented_history))

Reply via email to