help-bash
[Top][All Lists]
Advanced

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

Re: history substitution with "dashed" commands : !my-commadn


From: Chet Ramey
Subject: Re: history substitution with "dashed" commands : !my-commadn
Date: Thu, 28 Nov 2019 14:47:24 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.9.1

On 11/28/19 8:38 AM, Sukolyn Ljubljana via wrote:
> hi,
> i'm trying to do history substitution with command which name contains a dash,
> $ my-func() { echo $FUNCNAME;}$ my-funcmy-func$ !my-f-bash: f: command not 
> found$ !my-f:s/ion/blah/f:s/ion/blah/-bash: f:s/ion/blah/: No such file or 
> directory
> is there anything to do to succeed history substitutions with such commands ?

The `-' is treated as a word designator. The event is !my, which selects
the previous command line (my-func), then the word designator `-'
introduces a range. You could make an argument that the non-digit following
the range specifier disqualifies it as a word designator, but neither bash
(readline, really) nor csh treats it that way. csh throws an error ("Bad
! arg selector"), but bash/readline just treats it as a degenerate range
that doesn't expand to anything and appends the rest of the word (f-bash)
and leaves that as the result of the 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]