[Top][All Lists]

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

Re: Issues with history substitution and its documentation

From: Chet Ramey
Subject: Re: Issues with history substitution and its documentation
Date: Tue, 19 Nov 2019 09:50:15 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.2.2

On 11/18/19 12:40 PM, Jim Monte wrote:
Thank you for looking into all of these reports. My issue here was that in both cases there had not yet been any ?string? search, so they should behave the same way -- an event is not required to not have a most recent ?string? search. So if the default is to use an empty string as the previous string when there is none, for consistency from the perspective of the user, both instances of echo "!%" should output echo "" as the second one does.

That's not the issue. The `%' isn't part of the event selector; it's a
word designator. The `real' event is `!!', though it's abbreviated as `!'.
This is essentially equivalent to "!!:%".

Since the event selector is `!!', you need a previous history entry to
make that a valid event, and you don't have one. The history code complains
when you specify an invalid event -- it's the same as if you had specified
"!578" when you only have 12 history entries.

[root@localhost ~]# bash
[root@localhost ~]# echo "!%"
bash: !: event not found
[root@localhost ~]# echo a >/dev/nul
[root@localhost ~]# echo "!%"
echo ""

I don't know if you're not reading the history file at startup or if it's
due to something else, but you have an empty history list when you attempt
the first history expansion.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://tiswww.cwru.edu/~chet/

reply via email to

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