bug-bash
[Top][All Lists]
Advanced

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

Re: word selection in history expansion - !?word?%


From: Chet Ramey
Subject: Re: word selection in history expansion - !?word?%
Date: Mon, 12 Aug 2024 15:43:42 -0400
User-agent: Mozilla Thunderbird

On 8/9/24 2:15 AM, Jess M wrote:
Observed behaviour:
```
$ echo word01 word02 word03 floogle
word01 word02 word03 floogle
$ echo !?word?%
echo word03
word03
$ # I expected to get word01
$ echo $BASH_VERSION
5.2.26(1)-release
```

The bash manual for word designators sounds to me as if word01 should be
selected.

That's certainly the csh behavior.

Bash has done it this way for as long as its history expansion has been
implemented. It dates back to at least 1988-89. I think the idea (that
was a long time ago) was that it started as a way to perform searching for
readline, and in that case you want the history to basically be treated as
a single long string, in which you search backwards or forwards from the
current location. The csh-style history expansion code inherited that
behavior.

It should not be difficult to provide an option to do it the csh way, but
there's a lot of existing behavior there, so I don't know about making it
the default.

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

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

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