[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 15:21:39 -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:
> Fair enough; sorry for the vague report. I thought it was surprising that:
>
> 1. \! and \# increment at different times during command entry
OK, I see what you mean. They are incremented at different times, and by
different "agents". The command number (\#) is incremented after the shell
parses a complete command and before it is executed. The history number
(\!) increments when the first line of the command is read and returned and
bash calls add_history. It's the result of the division of responsibility
between bash and readline. The shell is the one responsible for adding
subsequent lines to the first history entry (`command-oriented history'),
so the history library has done it's job: it's incremented the history
number and is waiting for the next call to add_history().
Maybe the shell could special-case \! for the second and subsequent lines
of a multi-line command, but that seems tricky to get right.
How would you suggest capturing this in the documentation in a way that
would be clearer? The text from your previous message or something else?
Chet
--
``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/