bug-bash
[Top][All Lists]
Advanced

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

Re: Multi-word matching in history expansion


From: Chet Ramey
Subject: Re: Multi-word matching in history expansion
Date: Tue, 02 Oct 2007 17:37:40 -0400
User-agent: Thunderbird 2.0.0.6 (Macintosh/20070728)

The Wanderer wrote:

>>> I would be interested to find out, if someone is present who does
>>> know. I would also be interested to know the rationale behind the
>>> behaviour, given that the only potentially real-world scenario I
>>> can think of where this behaviour seems as if it would be useful is
>>> in adding e.g. the '-g' flag to the end of a compiler command line,
>>> but the other behaviour was useful to me in a wide variety of
>>> circumstances.
>>
>> It's a feature that was first implemented in csh, and bash attempts
>> to mimic the csh behavior.
> 
> That's the rationale for doing it in bash, but not the rationale for
> doing it at all.

That particular decision was made 30 years ago, and I doubt Bill Joy
is interested in revisiting it.

> 
>>> I would also be curious to know the exact reason why escaping the
>>> space does not cause it to be treated as part of the initial
>>> command to be matched and so form an effective workaround, but I
>>> suspect that there is no practical way to explain that better than
>>> is done by the source itself.
>>
>> Because history expansion simply does not honor backslash quoting in
>> that context, and whitespace delimits the history event.  It's no
>> more complicated (and no simpler) than that.
> 
> That's not a reason; that's just a description of the behaviour. I want
> to know *why* it does not honor it, and as I said, probably the only
> effective way to find that out is to read the source.

Because the code that looks for the delimiter marking the end of the
history event looks for whitespace characters, and does not skip the
next character when it encounters a backslash.

I'm really not sure how much more the source code will elucidate the
point; the implementation is fairly obvious from a description of the
behavior.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                       Live Strong.  No day but today.
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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