bug-bash
[Top][All Lists]
Advanced

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

Re: Inconsistent results when history -s is used within PROMPT_COMMAND


From: Chet Ramey
Subject: Re: Inconsistent results when history -s is used within PROMPT_COMMAND
Date: Tue, 16 Jun 2009 21:26:21 -0400
User-agent: Thunderbird 2.0.0.21 (Macintosh/20090302)

dennis wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: i486OS: linux-gnuCompiler: gccCompilation CFLAGS:  
> -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linux-gnu' 
> -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc' 
> -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   
> -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2 -Walluname output: 
> Linux emperor 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009 
> i686 GNU/LinuxMachine Type: i486-pc-linux-gnu
> Bash Version: 3.2Patch Level: 48Release Status: release
> Description:
> (Also reproduced in bash 4.0.16(1)-release on Fedora 11 when 
> HISTCONTROL=ignorespace.)
>         In a script that I developed which adds comments to the ends ofbash 
> history entries, if the entry contains a newline, history -s givesdifferent 
> results than if the entry does not contain a newline.
>         Specifically, the entry is duplicated (with comment added) when 
> there's a newline. The expected behavior is that the existing entry would 
> be replaced by the comment-appended version as it correctly is when there's 
> no newline.
>         I have attached a test script below which duplicates the 
> pertinentparts of my script, leaves out what isn't applicable to this 
> problem, and includes various features to aid in reproducing the problem. 
> It also includes further details of this issue.

This is the result of an interaction between compound or multiline
commands, command-oriented history, and history -s.  history -s
will not delete the previous history entry before pushing the new
entry if it's added to a previous entry as part of a compound
command.  Otherwise, history -s used within a compound command will
remove the entire compound command from the history list.

This seems to be an unusual case; I'm not inclined to change the
current behavior.  Better to have an extra command in the history
than delete them inadvertently.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer

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]