bug-bash
[Top][All Lists]
Advanced

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

Re: ^O gets stuck if there's a bunch of history


From: Chet Ramey
Subject: Re: ^O gets stuck if there's a bunch of history
Date: Mon, 19 Sep 2011 22:49:53 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2

On 9/17/11 8:41 AM, gregrwm wrote:
>>> Repeat-By:
>>> rm $HISTFILE                            #start with no history file
>>> exec -cl bash --norc --noprofile        #start with no history in memory
>>> pm=1.2.3.4                              #do some commands
>>> sb='echo sudo -uboo'
>>> ssb="$sb ssh -p1234 $pm cd boo;"
>>> $ssb 'echo run
>>> echo fox
>>> echo fun'
>>> exec -cl bash --norc --noprofile        #start over again
>>>
>>> #now do the same commands from history starting with pm= using ^O.  should 
>>> be no problem so far.
>>> for((i=0;i<1000;i++));do echo echo $i The quick brown fox jumps over the 
>>> lazy dog.>>$HISTFILE;done      #add some more history
>>> exec -cl bash --norc --noprofile        #start over again
>>>
>>> #now do the same commands from history starting with pm= using ^O.  i get 
>>> stuck doing echo fox over and over.  no fun.
>>
>> OK, without looking into it very deeply, I have to admit that I can't see
>> a real problem.  You just added 1000 identical lines directly to the
>> history file and read it into a fresh bash invocation.  Wouldn't you
>> expect that they would all end up in the history list?  If you don't want
>> to execute each line from the history, you should be able to just go to
>> the end of the history with M-> or edit the line you're currently on and
>> hit return.
> 
> hi chet,
> sorry for not being more clear.
> once the history file is big enough, when i go back to the commands i
> want to repeat (using ^R to find pm=), and start executing them with
> ^O, it gets stuck on the multiline quoted command, which doesn't
> happen before all the other history was in there.  my repeat-by
> sequence should walk you though seeing it work before adding the extra
> history and seeing it get stuck once the extra history is there.  i'm
> hopeful it's repeatable for you.

OK, thanks for the clarification.  I see the problem.  It's an incorrect
calculation of the `next history line' in operate_and_get_next() that
mishandles this particular case.

By default, bash limits the size of the history to 500 commands, which
means you get the commands you executed and around the last 490 or so
`echo's you wrote to the history file in the history list.  The history
list is full up.

operate_and_get_next assumes that the line will be added to the history,
either at the end (shuffling everything down one) if you've reached the
$HISTSIZE limit, or as the next entry numerically.  In this case, an
incomplete command with command-oriented-history set to 1, the line is
not added as a separate history entry, so the history never gets shuffled
down and the current entry stays at the same command.

The code has been this way for over 20 years, so this is a
very-infrequently-encountered problem. I will have to look at the startup
hook the command uses to see if I can fix it up there.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
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]