While '{' and '}' are rare in path names, somebody may still
use them or deal with software which does (e.g. GNU arch).
$re_map{$p eq '\\' ? '' : do {
if ($1 eq '[') { ++$in_bracket }
elsif ($1 eq ']') { --$in_bracket }
$re_map{$p eq '\\' ? '' : do {
if ($1 eq '[') { ++$in_bracket }
elsif ($1 eq ']') { --$in_bracket }
+ elsif ($1 eq ',') { ++$qm } # no change
$p = $1;
}} // do {
$p = $1;
($p eq '-' && $in_bracket) ? $p : (++$qm, "\Q$p")
}!sge);
# bashism (also supported by curl): {a,b,c} => (a|b|c)
$p = $1;
}} // do {
$p = $1;
($p eq '-' && $in_bracket) ? $p : (++$qm, "\Q$p")
}!sge);
# bashism (also supported by curl): {a,b,c} => (a|b|c)
- $re =~ s/([^\\]*)\\\{([^,]*?,[^\\]*?)\\\}/
- (my $in_braces = $2) =~ tr!,!|!;
- $1."($in_braces)";
- /sge;
+ $changes += ($re =~ s/([^\\]*)\\\{([^,]*,[^\\]*)\\\}/
+ (my $in_braces = $2) =~ tr!,!|!;
+ $1."($in_braces)";
+ /sge);
($changes - $qm) ? $re : undef;
}
($changes - $qm) ? $re : undef;
}
is_deeply($glob2re->('a}'), undef, 'open right brace');
is_deeply($glob2re->('*.[ch]'), '[^/]*?\\.[ch]', 'suffix glob');
is_deeply($glob2re->('{[a-z],9,}'), '([a-z]|9|)' , 'brace with range');
is_deeply($glob2re->('a}'), undef, 'open right brace');
is_deeply($glob2re->('*.[ch]'), '[^/]*?\\.[ch]', 'suffix glob');
is_deeply($glob2re->('{[a-z],9,}'), '([a-z]|9|)' , 'brace with range');
+is_deeply($glob2re->('\\{a,b\\}'), undef, 'escaped brace');
+is_deeply($glob2re->('\\\\{a,b}'), '\\\\\\\\(a|b)', 'fake escape brace');