mainThe GNU Bourne-Again SHell - Support: sr #108530, History duplicates with multiple...


sr #108530: History duplicates with multiple sessions

Submitter:  Balaco <balacobaco>
Submitted:  Thu 13 Mar 2014 08:14:09 AM UTC
Votes: 40
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Wont Do
Privacy:  Public Assigned to:  None
Open/Closed:  Open Operating System:  None
* Mandatory Fields

Add a New Comment Rich Markup

Wed 11 Nov 2015 11:33:21 PM UTC, comment #5: 

I never looked at Bash's source code. For its popularity, I have guessed that many others would know it much better than I can do for the first time. Although I have a good familiarity with Bash scripts, source code is not exactly guaranteed to be easier with that.

In a few days I may expend a few hours with your ideas. If needed, would you help it to progress?

Balaco <balacobaco>
Wed 11 Nov 2015 09:18:44 PM UTC, comment #4: 

There are two utilities distributed with readline that can remove commands from history files.  hist_erasedups removes duplicate commands from a history file, and hist_purgecmd removes commands matching a pattern or string.

Readline is not well structured to remove duplicates when writing a history file because of the in-memory nature of the history list.  That's why the utilities above exist.

If you would like to take a shot at taking the functions that do the work from the utilities and incorporating them into the history library itself, please do so and let me know what happens.  You could add additional options to the bash `history' builtin to use them (maybe -E and -D).

Chet Ramey <chet>
Group administrator
Wed 11 Nov 2015 08:12:20 PM UTC, comment #3: 

Not a solution, but something that can be useful to users until it is fixed:

Balaco <balacobaco>
Wed 11 Nov 2015 08:07:53 PM UTC, comment #2: 

Is there something I can do to help this problem starting being fixed?

The amount of users and discussions that happened with this bug isn't big enough to represent its importance?

There are several discussions and partial fixes - mostly not easily repeatable or takes a few minutes.

Balaco <balacobaco>
Wed 13 May 2015 01:49:19 PM UTC, comment #1: 

Is there anyone reading here?,

Balaco <balacobaco>
Thu 13 Mar 2014 08:14:09 AM UTC, original submission:  

People who use history option 'erasedups' doesn't have it working in practice.

To easily make the problem happen we simply open 2 (or more) simultaneous sessions, or nested sessions (like ssh from access machine to other machines on a private network, very common).

Bash's history is kept right for an open session. When the session 1 closes it will write its history, no duplicates. But when the other session closes it won't account for duplicate commands done on the parallel session 1. Duplicates will grow very large this way.

Very bad side effect: a person choose HISTSIZE and HISTFILESIZE based on his/hers expectations. But the dups described make the practical history of different commands the person has much smaller than the desired values.

This is a very old bash issue, and simple internet searches show that people tried and try many odd things to overcome this problem. Can it be fixed and documented so we may use Bash's history in a better way?

The same problem happens when 2 nested sessions are closed abnormally, for example in a network failure.

Balaco <balacobaco>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by chet (Updated the item)
  • -email is unavailable- added by balacobaco (Voted in favor of this item)
  • -email is unavailable- added by balacobaco (Submitted the item)

    There are 40 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-01-17 chet StatusPostponed Wont Do
    2015-11-11 chet Severity4 - Important 3 - Normal
    2015-06-06 chet StatusNone Postponed
    2015-05-13 balacobaco Carbon-Copy- Added balacobaco

    Back to the top

    Powered by Savane 3.13-b921.
    Corresponding source code