On 3/17/17 5:43 PM, Grisha Levit wrote:
> On Tue, Mar 14, 2017 at 9:07 PM, Chet Ramey <chet.ra...@case.edu> wrote:
>> when PS1 is expanded the first time, the "current" history entry is the
>> one corresponding to the last command entered
> 
>> PS2 looks at the current history entry, which is 530 since we've
>> started on it.
> 
> I think I'm missing something. It seems that when PS1 is expanded \! *does*
> match what will eventually become the history number of the command-to-be-
> -entered, while PS2 does not. i.e. I can't see how we've started on the second
> line of history if the current input will still be stored in the first.

OK, let me take a look.

> 
> $ PS1='\!      $ ' PS2=${PS1/$/>}; history -c
> 1      $ : 1.1 \
> 2      > : 1.2
> 2      $ fc -l -1
> 1        : 1.1 : 1.2
> 
>> When the first line is entered, the history number and command numbers
>> get incremented
> 
> There seems to be a mismatch: the history number is incremented and the
> command number is not:

This is true; the command number is incremented only when the complete
command is parsed and before it's executed, before PS0 is displayed.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to