Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HISTCONTROL=erasedups

14 views
Skip to first unread message

Thilo Six

unread,
May 9, 2007, 5:20:13 PM5/9/07
to bug-...@gnu.org
Hello

Today i came across this neat feature but unfortunately i have a problem with it.

~/.bashrc
<----------------------------
export HISTCONTROL=erasedups
---------------------------->

$ history
1 history

$ top
$ htop
$ top
$ htop
$ history
1 top
2 htop
3 history


i close this shell and open a new terminal:

$ history
1 top
2 htop
3 history

$ top
$ htop

i close this shell again and *now* i get:

$ history
1 top
2 htop
3 top
4 htop
5 history

So it seems to me entries already written to ~/.bash_history are not
"eliminated".
Is this the supposed behaviour?

man bash:
<---------------------------------------------------------------
A value of erasedups causes all previous lines matching the current line
to be removed from the history list before that line is saved.
--------------------------------------------------------------->

>From that i would think only *one* appearance of entries that are the same
would be saved.

please give me a hint.

TIA Thilo
--
i am on Ubuntu 2.6 KDE
- some friend of mine

gpg key: 0x4A411E09

Thilo Six

unread,
May 9, 2007, 5:37:21 PM5/9/07
to bug-...@gnu.org
Thilo Six wrote the following on 09.05.2007 23:20:
> Hello

<snip>

sorry forgot to mention:

$ echo $BASH_VERSION
3.2.13(1)-release

Chet Ramey

unread,
May 9, 2007, 11:46:29 PM5/9/07
to Thilo Six, bug-...@gnu.org, ch...@case.edu

The erasedups feature works correctly: it removes matching commands
from the history list, which is kept in memory. When the shell exits,
by default it appends the current history list to the history file.
If you want to force the history file to be completely rewritten, you
can use `history -w' at shell exit to rewrite it. There is, unfortunately,
currently no easy way to force the `rewrite-at-exit' behavior.

Chet


--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Live Strong. No day but today.
Chet Ramey, ITS, CWRU ch...@case.edu http://cnswww.cns.cwru.edu/~chet/


Bob Proulx

unread,
May 10, 2007, 1:46:18 AM5/10/07
to bug-...@gnu.org, Thilo Six
Chet Ramey wrote:
> If you want to force the history file to be completely rewritten, you
> can use `history -w' at shell exit to rewrite it. There is, unfortunately,
> currently no easy way to force the `rewrite-at-exit' behavior.

Could a shell trap be used to do this?

trap 'history -w' EXIT

I did not test this however. It is just a "brainstorm" idea.

Bob


Chet Ramey

unread,
May 10, 2007, 9:30:25 AM5/10/07
to b...@proulx.com, T....@gmx.de, bug-...@gnu.org, ch...@po.cwru.edu
> Chet Ramey wrote:
> > If you want to force the history file to be completely rewritten, you
> > can use `history -w' at shell exit to rewrite it. There is, unfortunately,
> > currently no easy way to force the `rewrite-at-exit' behavior.
>
> Could a shell trap be used to do this?
>
> trap 'history -w' EXIT

That's the way to force `history -w' at shell exit. There is no variable
setting to make that behavior the default without using a trap, however.

Chet

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

Chet Ramey, ITS, CWRU ch...@case.edu http://tiswww.tis.case.edu/~chet/


Thilo Six

unread,
May 10, 2007, 12:56:43 PM5/10/07
to bug-...@gnu.org
Chet Ramey wrote the following on 10.05.2007 05:46:

<snip>

> If you want to force the history file to be completely rewritten, you
> can use `history -w' at shell exit to rewrite it.

$ top


$ htop
$ top
$ htop
$ history
1 top
2 htop
3 history

$ history -w

in new shell:


$ history
1 top
2 htop

3 history -w
4 top
5 htop
6 history -w
7 history

> There is, unfortunately,
> currently no easy way to force the `rewrite-at-exit' behavior.

:( ic

I have tried this trap thingy also, but unfortunatly it doesn´t work either
it seems.

> Chet

OK then thank you and i would like to open a wishlist bug for it. ;)

bye Thilo

Thilo Six

unread,
May 10, 2007, 1:16:51 PM5/10/07
to bug-...@gnu.org
Thilo Six wrote the following on 10.05.2007 18:56:

<snip>

> OK then thank you and i would like to open a wishlist bug for it. ;)

...and in the interim we probably should add a notice to the manpage, that
erasedups currently deons´t work session persistent.

0 new messages