On Sun, Feb 20, 2022 at 05:38:06PM +0100, Andrea Monaco wrote: > > Hello, > > > 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? > > > > Let me know, > > Andrea Monaco
It's not that it's the error that prevents the command from being saved in the shell's history, it's the fact that it is a history expansion (albeit a failed one). History expansions are not saved in the history. If history expansions, like !! to execute the most recent command in history, was saved to the shell's command history, then what would the shell execute if you entered !! for the secand time in a row? -- Andreas (Kusalananda) Kähäri SciLifeLab, NBIS, ICM Uppsala University, Sweden .