bug-bash
[Top][All Lists]
Advanced

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

Re: DEL character treated specially when preceded by a backslash when us


From: Chet Ramey
Subject: Re: DEL character treated specially when preceded by a backslash when used in the RHS of the regex operator ([[ $'\177' =~ $'\\\177' ]])
Date: Sat, 18 Jan 2014 21:04:35 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

On 1/17/14, 9:07 AM, Greg Wooledge wrote:
> On Fri, Jan 17, 2014 at 08:53:07AM -0500, Chet Ramey wrote:
>> On 1/17/14 8:01 AM, Greg Wooledge wrote:
>>> I would expect [[ x =~ yx ]] to fail (return 1) every time. 
>>
>> There is a question about the correct behavior when y == '\', since the
>> backslash is special to pattern matching.  When matching a pattern or a
>> regexp, do you think x =~ \x should succeed, because the backslash acts
>> as an escape?
> 
> OK, I see your point.  Here are some more experiments:
> 
> imadev:~$ [[ x =~ \x ]] ; echo $?
> 0
> imadev:~$ bs='\'
> imadev:~$ [[ x =~ ${bs}x ]] ; echo $?
> 0
> imadev:~$ [[ x =~ $'\\'x ]] ; echo $?
> 1
> 
> You get to decide which one(s) are bugs. ;-)

The second.  In the first case, the backslash disappears before we even hit
the regexp matcher as an outcome of the word expansions.  The second and
third should be equivalent.  I'm still working through it.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
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]