bug-bash
[Top][All Lists]
Advanced

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

Re: History counts backwards


From: Geoff Kuenning
Subject: Re: History counts backwards
Date: 01 Jan 2005 14:50:30 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

> > Am I completely misunderstanding how bash numbers history entries?
> 
> The numbering is simply the index into a list of history entries.  If some
> entries are removed, the numbering changes.  The history number is not
> stored anywhere in the history entry itself; it is computed on the fly.

In the last few minutes I have become convinced that this is incorrect
behavior, and that the history number must be stored internally.
Here's some slightly edited output from my terminal window.  You'll
see that I tried to re-execute several commands by number, and got a
small surprise.  I'm fortunate that it wasn't a nasty one like "rm -rf
*".

    bow:502> history
    [...]
      494  /bin/rm /tmp/foo9
      495  s
      496  mysql -t -e 'select * from person;' test 
      497  mysql -B -e 'select * from person;' test 
      498  mysql -E -e 'select * from person;' test 
      499  mysql -E -B -e 'select * from person;' test 
      500  mysql
      501  mysql -E -t -e 'select * from person;' test 
      502  history
    bow:503> !496
    mysql -t -e 'select * from person;' test 
    [... mysql output]
    bow:503> !497
    mysql -E -e 'select * from person;' test 
    [... mysql output -- but note that this was NOT command 497 from above!]
    bow:503> !498
    mysql
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 24 to server version: 4.0.21-Max
    [... again, note that it's not the commane from above!]

Calculating the history number dynamically causes simple sequences
like the above to misbehave badly.  For the time being, I think I'll
turn off erasedups in hopes of making it behave a bit better.
-- 
    Geoff Kuenning   geoff@cs.hmc.edu   http://www.cs.hmc.edu/~geoff/

You know you're a parent when you hear yourself utter the words,
"Throw up on Daddy's shoulder...good girl."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]