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


sr #108530: History duplicates with multiple sessions

Submitted by:  Balaco <balacobaco>
Submitted on:  Thu 13 Mar 2014 08:14:09 AM UTC  
Votes:  40  
Category: NonePriority: 5 - Normal
Severity: 3 - NormalStatus: Postponed
Privacy: PublicAssigned to: None
Open/Closed: OpenOperating System: None

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


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>
Project 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 File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 40 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 11 Nov 2015 09:19:08 PM UTCchetSeverity4 - Important=>3 - Normal
    Sat 06 Jun 2015 08:34:03 PM UTCchetStatusNone=>Postponed
    Wed 13 May 2015 01:47:43 PM UTCbalacobacoCarbon-Copy-=>Added balacobaco

    Back to the top

    Powered by Savane 3.1-cleanup