[Top][All Lists]

[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: Fri, 17 Jan 2014 14:48:54 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.1.1

On 1/17/14 2:30 PM, Eduardo A. Bustamante López wrote:
> On Fri, Jan 17, 2014 at 08:43:46AM -0500, Chet Ramey wrote:
>> On 1/16/14 6:46 PM, Eduardo A. Bustamante López wrote:
>>> The DEL ($'\177') character does not behave like the other control
>>> characters when used with the regex operator inside the test keyword.
>> This has to do with the expansion of $r and that $r includes a backslash.
>> When combined with the internal quoting bash does, and the fact that the
>> backslash is special to pattern matching, we end up with this problem.
>> I've only thought about it a little so far, but I don't know if there's a
>> quick or simple fix.  This may have to wait until after bash-4.3 is
>> released.
>> Chet
> I understand that the backslash preceding a character *could* make it
> to not match, though $'\177' is the *only* non-graphic character that
> has this behavior.

No, I understand the problem.  The DEL is special to bash's internal
expansion and quoting (this just came up in another message earlier
this week).  That, combined with the slightly inconsistent word expansion
bash does for the operands in the [[ command and the fact that there is a
backslash in the expansion, results in a problem that seemingly affects
only DEL.  There are other characters that aren't handled exactly right,
including \001, but fortunate circumstances make those cases work.  And
it's not that the backslash gets passed to the regexp engine, but that its
presence causes bash to do the wrong thing when there is a DEL in the

It's not understanding the problem, or the combination of things that
causes it, but figuring out the right solution.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

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