"Word" means something different in history expansion than it does in the rest of the shell, because it happens before the normal lexical processing. In effect, it means the same as an identifier in C.
A history expansion consists of a line selector (!cmdname) optionally followed by colon and a word range selector, where the colon can be omitted if the word range selector does not begin with an alphanumeric. The '-' is being interpreted as the start of a word range selector, meaning all the words except the last, which since "foo-bar" was a single word, no words at all; and then the "b" stands alone as the only text on the line. -Martin On Fri, 14 Apr 2023 at 04:38, James Cloos <cl...@jhcloos.com> wrote: > with bash-5.0.3, !foo-b reports > b > bash: b: command not found > > even when foo-bar is in history. > > there is nothing in the history expansion sectio of the man page which > would eve suggest that - cannot be part of string. > > -JimC > -- > James Cloos <cl...@jhcloos.com> OpenPGP: 0x997A9F17ED7DAEA6 > >