bug-bash
[Top][All Lists]
Advanced

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

Re: !; is interpreted as an history expansion that can never match anyth


From: Chet Ramey
Subject: Re: !; is interpreted as an history expansion that can never match anything
Date: Thu, 10 Aug 2023 11:38:49 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 8/8/23 3:30 PM, Dale R. Worley wrote:
Emanuele Torre <torreemanuele6@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    chet@case.edu    http://tiswww.cwru.edu/~chet/




reply via email to

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