bug-bash
[Top][All Lists]
Advanced

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

Re: \! and \# in PS1 vs PS2 vs PS4, PS0 and ${var@P}


From: Chet Ramey
Subject: Re: \! and \# in PS1 vs PS2 vs PS4, PS0 and ${var@P}
Date: Sat, 18 Mar 2017 14:58:57 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 3/17/17 5:43 PM, Grisha Levit wrote:
> On Tue, Mar 14, 2017 at 9:07 PM, Chet Ramey <chet.ramey@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    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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