On 8/8/23 3:30 PM, Dale R. Worley wrote:
Emanuele Torre <torreemanue...@gmail.com> writes:
! followed by a ; or another terminator is interpreted as an history
expansion with no pattern that can never match anything.
$ !; echo hi
bash: !: event not found
$ !&& echo hi
bash: !: event not found
IMHO it is more to the point that in the manual page it says
!string
Refer to the most recent command preceding the current position
in the history list starting with string.
without defining "string".
It looks like the actual definition is "everything from the ! to the end
of the word", taking into account
I would have thought it obvious, since history expansion specifiers don't
span words.
The line is broken into words
in the same fashion as when reading input, so that several metacharac‐
ter-separated words surrounded by quotes are considered one word. His‐
tory expansions are introduced by the appearance of the history expan‐
sion character, which is ! by default.
With the significant detail that the ! need not be the first character
of the word.
That's useful to add.
So I think the manual page could be improved by adding *...*:
!string
Refer to the most recent command preceding the current position
in the history list starting with string. *All characters
until the start of the word designator or end of the word
are part of string.*
It's more general than that: the event designator is the portion of the
word from the history expansion character to a word designator or the
end of the word.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/