[pacman-dev] [PATCH 4/6] bacman: use globbing in place of regex
Dan McGee
dpmcgee at gmail.com
Thu Sep 29 14:14:46 EDT 2011
On Thu, Sep 29, 2011 at 12:46 PM, Dave Reisner <d at falconindy.com> wrote:
> On Fri, Sep 30, 2011 at 01:14:04AM +0800, lolilolicon wrote:
>> The original regex is also not accurate (should be ^[A-Z]+$).
>>
>> Signed-off-by: lolilolicon <lolilolicon at gmail.com>
>> ---
>> contrib/bacman.in | 4 ++--
>> 1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/contrib/bacman.in b/contrib/bacman.in
>> index d43bf78..c69ab6f 100755
>> --- a/contrib/bacman.in
>> +++ b/contrib/bacman.in
>> @@ -143,7 +143,7 @@ while read i; do
>> continue
>> fi
>>
>> - if [[ "$i" =~ %[A-Z]*% ]] ; then
>> + if [[ "$i" == %+([A-Z])% ]] ; then
>
> nak. This is affected by locale. If we're going to fix it, fix it
> correctly and use [[:upper:]]. See fun commits like 541c2470b8ad.
You sure about this? We're trying to match %NAME%, %VERSION%, %FILES%,
etc. here, which we know will be ASCII 7-bit characters in all cases.
Also note that the only purpose of this regex/glob/whatever is to
short-circuit the case statement, so it isn't that big of deal if we
have false positives. We just can't have false negatives.
-Dan
More information about the pacman-dev
mailing list