[Top][All Lists]

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

Re: command line not saved after "event not found" error

From: Chet Ramey
Subject: Re: command line not saved after "event not found" error
Date: Sun, 20 Feb 2022 16:15:36 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.4.1

On 2/20/22 11:38 AM, Andrea Monaco wrote:

on my bash 5.0.3, when I input

   $ foo!\

I get "bash: !\: event not found", which I think is appropriate, but the
line doesn't get saved in history.  The same doesn't happen for other
errors, for example "command not found".

Is this behavior intended?

Yes. History substitution isn't the same kind of error as a command not
found or word expansion error. As you discovered, it takes place before
any further history processing, like saving to the history list.

History substitution can be viewed as a line containing commands to
select and modify a previous history entry, not a separate line itself. If
those commands fail, why save them? So it's the line following history
expansion that gets saved to the history.

That means a history expansion failure has historically caused the line
to be immediately discarded, and not passed onto further processing stages.

If you want an opportunity to re-edit a failed history expansion, set the
`histreedit' shell option.

``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]