From: Robert Bonomi on
In article <hu7p4u$bca$1(a)canard.ulcc.ac.uk>, George <me(a)me.com> wrote:
>On 03/06/2010 00:50, Thomas 'PointedEars' Lahn wrote:
>>
>> | s/_old_/_new_/ | Substitute _new_ for the first
>> occurrence of _old_ in the event | line. Any delimiter can be
>> used in place of /. The final | delimiter is optional
>> if it is the last character of the event | line. The delimiter
>> may be quoted in _old_ and _new_ with a single | backslash.
>> If& appears in _new_, it is replaced by _old_. A sin‐ | gle
>> backslash will quote the&. If _old_ is null, it is set to |
>> the last _old_ substituted, or, if no previous history substitu‐ |
>> tions took place, the last string in a !?_string_[?] search.
>
>This does not mean that old could not be a regular expression though,
>does it?

Take the language -literally-, it says 'the first occurrence of _old_' ,
*NOT* 'the first match of the pattern...'.

It's going to be a literal match, not a RE match.

> From the example it looks like it can not be, but this is not
>explicitly mentioned in the man page (or online, at least on the pages
>that I looked at).

Is, *if* you recognize that the -absence- of something is as important as
the presence of something else.

It does not say 'pattern', or 'RE' -- thus it _is- safe to assume 'literal'
only.

Think how you would have written that 'substitute...' sentence, _if_
'old' was allowed to be an RE. it would have been significantly different,
wouldn't it. Now ask yourself why it was -not- written as something close
to what you just came up with. obvious answer, "that description is not
accurate". right back in the same corner 'no REs allowed'. <grin>
>
>> $ ls -l test/ [...] $ !!:0-1 test2/ ls -l test2/ [...] $ ls -l -a
>> test/ [...] $ !!:0- test2/ ls -l -a test2/ [...]
>
>I know, I only used it as an example. This not the command I want to
>run, the "real" question was: can I have regular expressions in history
>substitution using the s modifier or only string literals? From your
>examples and my experience I would say string literals only, but if
>someone could give a definite answer, that would be great.
>
>Regards,
>George