[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bash-bug
Subject:    Re: history fails with - in string
From:       Martin D Kealey <martin () kurahaupo ! gen ! nz>
Date:       2023-04-13 22:06:47
Message-ID: CAN_U6MV7nAV0hnDgoQ+Dy85Dc7jQuyA6RGYTcfZvwO=jtxm51A () mail ! gmail ! com
[Download RAW message or body]

"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 <cloos@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 <cloos@jhcloos.com>         OpenPGP: 0x997A9F17ED7DAEA6
>
>
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic