bug-bash
[Top][All Lists]
Advanced

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

Re: Infinite loop in bash glob matching


From: Chet Ramey
Subject: Re: Infinite loop in bash glob matching
Date: Thu, 18 May 2017 15:15:16 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.1.1

On 5/18/17 2:29 AM, Zoltán Herczeg wrote:
>> I read this as saying that it's a requirement on the application to ensure
>> that character classes are correctly formed, and it's unspecified behavior
>> if they're not.
>>
>> So you're right: people should not count on shells treating improperly-
>> formed character classes as literal characters.
> 
> Thank you for the explanation.
> 
> I think throwing an error would be better than an undefined behaviour. Bash 
> throws error for solo parenthesis, a similar technique could be used here.

That's not a good example, since a parenthesis is a shell metacharacter,
and an unquoted paren in a place where it's not syntactially valid is a
syntax error.  The choice here is between not matching because the pattern
is invalid (the most common shell behavior) and treating the stray `[:'
as characters to be matched because they don't form a valid pattern (the
glibc behavior that Eduardo noted.)

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



reply via email to

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