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: Dan Douglas
Subject: Re: DEL character treated specially when preceded by a backslash when used in the RHS of the regex operator ([[ $'\177' =~ $'\\\177' ]])
Date: Fri, 17 Jan 2014 11:01:08 -0600

On Fri, Jan 17, 2014 at 8:07 AM, Greg Wooledge <wooledg@eeg.ccf.org> 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. ;-)

Looks a lot like that other issue in which the function of escapes and quotes
are ambiguous depending on whether they're literal and during which expansion
phase and in which context they appear in.

I covered a lot of possibilities with this test but there could be more:
http://permalink.gmane.org/gmane.comp.shells.bash.bugs/20564

IIRC ksh eventually changed some of their behavior and bash might have too. It
applies to both pattern matching and pathname expansion.



reply via email to

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