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: Mon, 01 Oct 2007 21:43:50 -0400
User-agent: Thunderbird 2.0.0.6 (Macintosh/20070728)

The Wanderer wrote:
> (And again.)
> 
> Bob Proulx wrote:
> 
>> The Wanderer wrote:
>>
>>> Quite some time and several varyingly-significant updates of bash
>>> ago, I was able to perform history expansion on multi-word
>>> commands.
>>>
>>> At present and for some while now, [!ls /h] instead expands to
>>>
>>> ls /tmp/ /h
>>
>> This is also what csh does in this situation too.  This type of
>> history substitution originated with csh and it would be the standard
>> against which other implementations would be compared.
> 
> That makes a certain amount of sense, although the behaviour itself
> still does not.
> 
> What does csh do with e.g.
> 
> !ls\ /h
> 
> (that is, attempting to escape the space so as to prevent tokenizing
> them separately)? I do not have csh installed, so I can't test. 

Bash imitates the csh behavior, and csh does not honor the escape.


> 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.

> 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.

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]