Skip to content

Instantly share code, notes, and snippets.

@joanbm
Last active April 4, 2020 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joanbm/a9277f30a2a1c8a50454ede43065544c to your computer and use it in GitHub Desktop.
Save joanbm/a9277f30a2a1c8a50454ede43065544c to your computer and use it in GitHub Desktop.
#!/bin/bash
# shellcheck disable=SC1003
set -eEuo pipefail
# Converts a list of wildcard patterns, as defined by glob(7) and used
# by e.g. GNU find for the -path switch, to a single regular
# expression.
function ShellPatternsToRegex() {
local patterns=("$@")
local regexps=()
local pattern
for pattern in "${patterns[@]}"
do
local regexp='^'
while [[ "$pattern" =~ ^([^][*?$\(\)*+.\\^{|]*)([][*?$\(\)*+.\\^{|}])(.*)$ ]] # split by glob special character
do
regexp=$regexp${BASH_REMATCH[1]}
pattern=${BASH_REMATCH[3]}
case "${BASH_REMATCH[2]}" in
'[')
if [[ "$pattern" =~ ^(!?)(\]?[^]]*\])(.*)$ ]]
then
regexp=$regexp'['
if [[ -n "${BASH_REMATCH[1]}" ]]
then
regexp=$regexp'^'
fi
regexp=$regexp${BASH_REMATCH[2]}
pattern=${BASH_REMATCH[3]}
else # '[' without matching ']'
regexp=$regexp'\['
fi
;;
'*')
regexp=$regexp'.*'
;;
'?')
regexp=$regexp'.'
;;
'^'|']')
regexp=$regexp'\'"${BASH_REMATCH[2]}"
;;
*)
regexp=$regexp'['"${BASH_REMATCH[2]}"']'
;;
esac
done
regexp=$regexp$pattern'$'
regexps+=("$regexp")
done
( IFS='|' ; echo "${regexps[*]}" )
}
#: Test
#ShellPatternsToRegex '*'
#ShellPatternsToRegex 'a?c'
#ShellPatternsToRegex 'a[b'
#ShellPatternsToRegex 'a[b]c'
#ShellPatternsToRegex 'a[!b]c'
#ShellPatternsToRegex 'a[][]c'
#ShellPatternsToRegex 'a[!][]c'
#ShellPatternsToRegex 'a*' 'b*' 'c*'
#
#ShellPatternsToRegex 'a.b'
#ShellPatternsToRegex 'a(b)c'
#ShellPatternsToRegex 'a^c'
#ShellPatternsToRegex 'a.*c'
function TestGlobPattern() {
local locale="$1"
local string="$2"
local pattern="$3"
local result="$4"
regex=$(ShellPatternsToRegex "$pattern")
local expected
if LC_ALL="$locale" echo "$string" | LC_ALL="$locale" grep -E "$regex" >/dev/null; then
expected="0"
else
expected="NOMATCH"
fi
local result_str
[[ "$expected" == "$result" ]] && result_str="PASS" || result_str="FAIL"
echo "[$result_str] locale=$locale string=$string pattern=$pattern regex=$regex result=$result"
}
# ----------------------------------------------------
# TESTS FROM tst-fnmatch.input FROM glibc-2.3.1 FOLLOW
# ----------------------------------------------------
# Tests for fnmatch.
# Copyright (C) 2000-2020 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# Contributes by Ulrich Drepper <drepper@redhat.com>.
#
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
# <https://www.gnu.org/licenses/>.
# Derived from the IEEE 2003.2 text. The standard only contains some
# wording describing the situations to be tested. It does not specify
# any specific tests. I.e., the tests below are in no case sufficient.
# They are hopefully necessary, though.
#
# See:
#
# http://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap09.html
#
# > RE Bracket Expression
# >
# > Range expressions are, historically, an integral part of REs.
# > However, the requirements of "natural language behavior" and
# > portability do conflict. In the POSIX locale, ranges must be treated
# > according to the collating sequence and include such characters that
# > fall within the range based on that collating sequence, regardless
# > of character values. In other locales, ranges have unspecified behavior.
# > ...
# > The current standard leaves unspecified the behavior of a range
# > expression outside the POSIX locale. This makes it clearer that
# > conforming applications should avoid range expressions outside the
# > POSIX locale, and it allows implementations and compatible user-mode
# > matchers to interpret range expressions using native order, CEO,
# > collation sequence, or other, more advanced techniques. The concerns
# > which led to this change were raised in IEEE PASC interpretation
# > 1003.2 #43 and others, and related to ambiguities in the
# > specification of how multi-character collating elements should be
# > handled in range expressions. These ambiguities had led to multiple
# > interpretations of the specification, in conflicting ways, which led
# > to varying implementations. As noted above, efforts were made to
# > resolve the differences, but no solution has been found that would
# > be specific enough to allow for portable software while not
# > invalidating existing implementations.
#
# Therefore, using [a-z] does not make much sense except in the C/POSIX locale.
# The new iso14651_t1_common lists upper case and lower case Latin characters
# in a different order than the old one which causes surprising results
# for example in the de_DE locale: [a-z] now includes A because A comes
# after a in iso14651_t1_common but does not include Z because that comes
# after z in iso14651_t1_common.
#
# This lead to several bugs and problems with user scripts that do not
# expect [a-z] to match uppercase characters.
#
# See the following bugs:
# https://sourceware.org/bugzilla/show_bug.cgi?id=23393
# https://sourceware.org/bugzilla/show_bug.cgi?id=23420
#
# No consensus exists on how best to handle the changes so the
# iso14651_t1_common collation element order (CEO) has been changed to
# deinterlace the a-z and A-Z regions.
#
# With the deinterlacing commit ac3a3b4b0d561d776b60317d6a926050c8541655
# could be reverted to re-test the correct non-interleaved expectations.
#
# Please note that despite the region being deinterlaced, the ordering
# of collation remains the same. In glibc we implement CEO and because of
# that we can reorder the elements to reorder ranges without impacting
# collation which depends on weights. The collation element ordering
# could have been changed to include just a-z, A-Z, and 0-9 in three
# distinct blocks, but this needs more discussion by the community.
# B.6 004(C)
TestGlobPattern C "!#%+,-./01234567889" "!#%+,-./01234567889" 0
TestGlobPattern C ":;=@ABCDEFGHIJKLMNO" ":;=@ABCDEFGHIJKLMNO" 0
TestGlobPattern C "PQRSTUVWXYZ]abcdefg" "PQRSTUVWXYZ]abcdefg" 0
TestGlobPattern C "hijklmnopqrstuvwxyz" "hijklmnopqrstuvwxyz" 0
TestGlobPattern C "^_{}~" "^_{}~" 0
# B.6 005(C)
TestGlobPattern C "\"$&'()" "\\\"\\$\\&\\'\\(\\)" 0
TestGlobPattern C "*?[\\\`|" "\\*\\?\\[\\\\\\\`\\|" 0
TestGlobPattern C "<>" "\\<\\>" 0
# B.6 006(C)
TestGlobPattern C "?*[" "[?*[][?*[][?*[]" 0
TestGlobPattern C "a/b" "?/b" 0
# B.6 007(C)
TestGlobPattern C "a/b" "a?b" 0
TestGlobPattern C "a/b" "a/?" 0
TestGlobPattern C "aa/b" "?/b" NOMATCH
TestGlobPattern C "aa/b" "a?b" NOMATCH
TestGlobPattern C "a/bb" "a/?" NOMATCH
# B.6 009(C)
TestGlobPattern C "abc" "[abc]" NOMATCH
TestGlobPattern C "x" "[abc]" NOMATCH
TestGlobPattern C "a" "[abc]" 0
TestGlobPattern C "[" "[[abc]" 0
TestGlobPattern C "a" "[][abc]" 0
TestGlobPattern C "a]" "[]a]]" 0
# B.6 010(C)
TestGlobPattern C "xyz" "[!abc]" NOMATCH
TestGlobPattern C "x" "[!abc]" 0
TestGlobPattern C "a" "[!abc]" NOMATCH
# B.6 011(C)
TestGlobPattern C "]" "[][abc]" 0
TestGlobPattern C "abc]" "[][abc]" NOMATCH
TestGlobPattern C "[]abc" "[][]abc" NOMATCH
TestGlobPattern C "]" "[!]]" NOMATCH
TestGlobPattern C "aa]" "[!]a]" NOMATCH
TestGlobPattern C "]" "[!a]" 0
TestGlobPattern C "]]" "[!a]]" 0
# B.6 012(C)
TestGlobPattern C "a" "[[.a.]]" 0
TestGlobPattern C "-" "[[.-.]]" 0
TestGlobPattern C "-" "[[.-.][.].]]" 0
TestGlobPattern C "-" "[[.].][.-.]]" 0
TestGlobPattern C "-" "[[.-.][=u=]]" 0
TestGlobPattern C "-" "[[.-.][:alpha:]]" 0
TestGlobPattern C "a" "[![.a.]]" NOMATCH
# B.6 013(C)
TestGlobPattern C "a" "[[.b.]]" NOMATCH
TestGlobPattern C "a" "[[.b.][.c.]]" NOMATCH
TestGlobPattern C "a" "[[.b.][=b=]]" NOMATCH
# B.6 015(C)
TestGlobPattern C "a" "[[=a=]]" 0
TestGlobPattern C "b" "[[=a=]b]" 0
TestGlobPattern C "b" "[[=a=][=b=]]" 0
TestGlobPattern C "a" "[[=a=][=b=]]" 0
TestGlobPattern C "a" "[[=a=][.b.]]" 0
TestGlobPattern C "a" "[[=a=][:digit:]]" 0
# B.6 016(C)
TestGlobPattern C "=" "[[=a=]b]" NOMATCH
TestGlobPattern C "]" "[[=a=]b]" NOMATCH
TestGlobPattern C "a" "[[=b=][=c=]]" NOMATCH
TestGlobPattern C "a" "[[=b=][.].]]" NOMATCH
TestGlobPattern C "a" "[[=b=][:digit:]]" NOMATCH
# B.6 017(C)
TestGlobPattern C "a" "[[:alnum:]]" 0
TestGlobPattern C "a" "[![:alnum:]]" NOMATCH
TestGlobPattern C "-" "[[:alnum:]]" NOMATCH
TestGlobPattern C "a]a" "[[:alnum:]]a" NOMATCH
TestGlobPattern C "-" "[[:alnum:]-]" 0
TestGlobPattern C "aa" "[[:alnum:]]a" 0
TestGlobPattern C "-" "[![:alnum:]]" 0
TestGlobPattern C "]" "[!][:alnum:]]" NOMATCH
TestGlobPattern C "[" "[![:alnum:][]" NOMATCH
TestGlobPattern C "a" "[[:alnum:]]" 0
TestGlobPattern C "b" "[[:alnum:]]" 0
TestGlobPattern C "c" "[[:alnum:]]" 0
TestGlobPattern C "d" "[[:alnum:]]" 0
TestGlobPattern C "e" "[[:alnum:]]" 0
TestGlobPattern C "f" "[[:alnum:]]" 0
TestGlobPattern C "g" "[[:alnum:]]" 0
TestGlobPattern C "h" "[[:alnum:]]" 0
TestGlobPattern C "i" "[[:alnum:]]" 0
TestGlobPattern C "j" "[[:alnum:]]" 0
TestGlobPattern C "k" "[[:alnum:]]" 0
TestGlobPattern C "l" "[[:alnum:]]" 0
TestGlobPattern C "m" "[[:alnum:]]" 0
TestGlobPattern C "n" "[[:alnum:]]" 0
TestGlobPattern C "o" "[[:alnum:]]" 0
TestGlobPattern C "p" "[[:alnum:]]" 0
TestGlobPattern C "q" "[[:alnum:]]" 0
TestGlobPattern C "r" "[[:alnum:]]" 0
TestGlobPattern C "s" "[[:alnum:]]" 0
TestGlobPattern C "t" "[[:alnum:]]" 0
TestGlobPattern C "u" "[[:alnum:]]" 0
TestGlobPattern C "v" "[[:alnum:]]" 0
TestGlobPattern C "w" "[[:alnum:]]" 0
TestGlobPattern C "x" "[[:alnum:]]" 0
TestGlobPattern C "y" "[[:alnum:]]" 0
TestGlobPattern C "z" "[[:alnum:]]" 0
TestGlobPattern C "A" "[[:alnum:]]" 0
TestGlobPattern C "B" "[[:alnum:]]" 0
TestGlobPattern C "C" "[[:alnum:]]" 0
TestGlobPattern C "D" "[[:alnum:]]" 0
TestGlobPattern C "E" "[[:alnum:]]" 0
TestGlobPattern C "F" "[[:alnum:]]" 0
TestGlobPattern C "G" "[[:alnum:]]" 0
TestGlobPattern C "H" "[[:alnum:]]" 0
TestGlobPattern C "I" "[[:alnum:]]" 0
TestGlobPattern C "J" "[[:alnum:]]" 0
TestGlobPattern C "K" "[[:alnum:]]" 0
TestGlobPattern C "L" "[[:alnum:]]" 0
TestGlobPattern C "M" "[[:alnum:]]" 0
TestGlobPattern C "N" "[[:alnum:]]" 0
TestGlobPattern C "O" "[[:alnum:]]" 0
TestGlobPattern C "P" "[[:alnum:]]" 0
TestGlobPattern C "Q" "[[:alnum:]]" 0
TestGlobPattern C "R" "[[:alnum:]]" 0
TestGlobPattern C "S" "[[:alnum:]]" 0
TestGlobPattern C "T" "[[:alnum:]]" 0
TestGlobPattern C "U" "[[:alnum:]]" 0
TestGlobPattern C "V" "[[:alnum:]]" 0
TestGlobPattern C "W" "[[:alnum:]]" 0
TestGlobPattern C "X" "[[:alnum:]]" 0
TestGlobPattern C "Y" "[[:alnum:]]" 0
TestGlobPattern C "Z" "[[:alnum:]]" 0
TestGlobPattern C "0" "[[:alnum:]]" 0
TestGlobPattern C "1" "[[:alnum:]]" 0
TestGlobPattern C "2" "[[:alnum:]]" 0
TestGlobPattern C "3" "[[:alnum:]]" 0
TestGlobPattern C "4" "[[:alnum:]]" 0
TestGlobPattern C "5" "[[:alnum:]]" 0
TestGlobPattern C "6" "[[:alnum:]]" 0
TestGlobPattern C "7" "[[:alnum:]]" 0
TestGlobPattern C "8" "[[:alnum:]]" 0
TestGlobPattern C "9" "[[:alnum:]]" 0
TestGlobPattern C "!" "[[:alnum:]]" NOMATCH
TestGlobPattern C "#" "[[:alnum:]]" NOMATCH
TestGlobPattern C "%" "[[:alnum:]]" NOMATCH
TestGlobPattern C "+" "[[:alnum:]]" NOMATCH
TestGlobPattern C "," "[[:alnum:]]" NOMATCH
TestGlobPattern C "-" "[[:alnum:]]" NOMATCH
TestGlobPattern C "." "[[:alnum:]]" NOMATCH
TestGlobPattern C "/" "[[:alnum:]]" NOMATCH
TestGlobPattern C ":" "[[:alnum:]]" NOMATCH
TestGlobPattern C ";" "[[:alnum:]]" NOMATCH
TestGlobPattern C "=" "[[:alnum:]]" NOMATCH
TestGlobPattern C "@" "[[:alnum:]]" NOMATCH
TestGlobPattern C "[" "[[:alnum:]]" NOMATCH
TestGlobPattern C "\\" "[[:alnum:]]" NOMATCH
TestGlobPattern C "]" "[[:alnum:]]" NOMATCH
TestGlobPattern C "^" "[[:alnum:]]" NOMATCH
TestGlobPattern C "_" "[[:alnum:]]" NOMATCH
TestGlobPattern C "{" "[[:alnum:]]" NOMATCH
TestGlobPattern C "}" "[[:alnum:]]" NOMATCH
TestGlobPattern C "~" "[[:alnum:]]" NOMATCH
TestGlobPattern C "\"" "[[:alnum:]]" NOMATCH
TestGlobPattern C "$" "[[:alnum:]]" NOMATCH
TestGlobPattern C "&" "[[:alnum:]]" NOMATCH
TestGlobPattern C "'" "[[:alnum:]]" NOMATCH
TestGlobPattern C "(" "[[:alnum:]]" NOMATCH
TestGlobPattern C ")" "[[:alnum:]]" NOMATCH
TestGlobPattern C "*" "[[:alnum:]]" NOMATCH
TestGlobPattern C "?" "[[:alnum:]]" NOMATCH
TestGlobPattern C "\`" "[[:alnum:]]" NOMATCH
TestGlobPattern C "|" "[[:alnum:]]" NOMATCH
TestGlobPattern C "<" "[[:alnum:]]" NOMATCH
TestGlobPattern C ">" "[[:alnum:]]" NOMATCH
TestGlobPattern C "\t" "[[:cntrl:]]" 0
TestGlobPattern C "t" "[[:cntrl:]]" NOMATCH
TestGlobPattern C "t" "[[:lower:]]" 0
TestGlobPattern C "\t" "[[:lower:]]" NOMATCH
TestGlobPattern C "T" "[[:lower:]]" NOMATCH
TestGlobPattern C "\t" "[[:space:]]" 0
TestGlobPattern C "t" "[[:space:]]" NOMATCH
TestGlobPattern C "t" "[[:alpha:]]" 0
TestGlobPattern C "\t" "[[:alpha:]]" NOMATCH
TestGlobPattern C "0" "[[:digit:]]" 0
TestGlobPattern C "\t" "[[:digit:]]" NOMATCH
TestGlobPattern C "t" "[[:digit:]]" NOMATCH
TestGlobPattern C "\t" "[[:print:]]" NOMATCH
TestGlobPattern C "t" "[[:print:]]" 0
TestGlobPattern C "T" "[[:upper:]]" 0
TestGlobPattern C "\t" "[[:upper:]]" NOMATCH
TestGlobPattern C "t" "[[:upper:]]" NOMATCH
TestGlobPattern C "\t" "[[:blank:]]" 0
TestGlobPattern C "t" "[[:blank:]]" NOMATCH
TestGlobPattern C "\t" "[[:graph:]]" NOMATCH
TestGlobPattern C "t" "[[:graph:]]" 0
TestGlobPattern C "." "[[:punct:]]" 0
TestGlobPattern C "t" "[[:punct:]]" NOMATCH
TestGlobPattern C "\t" "[[:punct:]]" NOMATCH
TestGlobPattern C "0" "[[:xdigit:]]" 0
TestGlobPattern C "\t" "[[:xdigit:]]" NOMATCH
TestGlobPattern C "a" "[[:xdigit:]]" 0
TestGlobPattern C "A" "[[:xdigit:]]" 0
TestGlobPattern C "t" "[[:xdigit:]]" NOMATCH
TestGlobPattern C "a" "[[alpha]]" NOMATCH
TestGlobPattern C "a" "[[alpha:]]" NOMATCH
TestGlobPattern C "a]" "[[alpha]]" 0
TestGlobPattern C "a]" "[[alpha:]]" 0
TestGlobPattern C "a" "[[:alpha:][.b.]]" 0
TestGlobPattern C "a" "[[:alpha:][=b=]]" 0
TestGlobPattern C "a" "[[:alpha:][:digit:]]" 0
TestGlobPattern C "a" "[[:digit:][:alpha:]]" 0
# B.6 018(C)
TestGlobPattern C "a" "[a-c]" 0
TestGlobPattern C "b" "[a-c]" 0
TestGlobPattern C "c" "[a-c]" 0
TestGlobPattern C "a" "[b-c]" NOMATCH
TestGlobPattern C "d" "[b-c]" NOMATCH
TestGlobPattern C "B" "[a-c]" NOMATCH
TestGlobPattern C "b" "[A-C]" NOMATCH
TestGlobPattern C "" "[a-c]" NOMATCH
TestGlobPattern C "as" "[a-ca-z]" NOMATCH
TestGlobPattern C "a" "[[.a.]-c]" 0
TestGlobPattern C "a" "[a-[.c.]]" 0
TestGlobPattern C "a" "[[.a.]-[.c.]]" 0
TestGlobPattern C "b" "[[.a.]-c]" 0
TestGlobPattern C "b" "[a-[.c.]]" 0
TestGlobPattern C "b" "[[.a.]-[.c.]]" 0
TestGlobPattern C "c" "[[.a.]-c]" 0
TestGlobPattern C "c" "[a-[.c.]]" 0
TestGlobPattern C "c" "[[.a.]-[.c.]]" 0
TestGlobPattern C "d" "[[.a.]-c]" NOMATCH
TestGlobPattern C "d" "[a-[.c.]]" NOMATCH
TestGlobPattern C "d" "[[.a.]-[.c.]]" NOMATCH
# B.6 019(C)
TestGlobPattern C "a" "[c-a]" NOMATCH
TestGlobPattern C "a" "[[.c.]-a]" NOMATCH
TestGlobPattern C "a" "[c-[.a.]]" NOMATCH
TestGlobPattern C "a" "[[.c.]-[.a.]]" NOMATCH
TestGlobPattern C "c" "[c-a]" NOMATCH
TestGlobPattern C "c" "[[.c.]-a]" NOMATCH
TestGlobPattern C "c" "[c-[.a.]]" NOMATCH
TestGlobPattern C "c" "[[.c.]-[.a.]]" NOMATCH
# B.6 020(C)
TestGlobPattern C "a" "[a-c0-9]" 0
TestGlobPattern C "d" "[a-c0-9]" NOMATCH
TestGlobPattern C "B" "[a-c0-9]" NOMATCH
# B.6 021(C)
TestGlobPattern C "-" "[-a]" 0
TestGlobPattern C "a" "[-b]" NOMATCH
TestGlobPattern C "-" "[!-a]" NOMATCH
TestGlobPattern C "a" "[!-b]" 0
TestGlobPattern C "-" "[a-c-0-9]" 0
TestGlobPattern C "b" "[a-c-0-9]" 0
TestGlobPattern C "a:" "a[0-9-a]" NOMATCH
TestGlobPattern C "a:" "a[09-a]" 0
# B.6 024(C)
TestGlobPattern C "" "*" 0
TestGlobPattern C "asd/sdf" "*" 0
# B.6 025(C)
TestGlobPattern C "as" "[a-c][a-z]" 0
TestGlobPattern C "as" "??" 0
# B.6 026(C)
TestGlobPattern C "asd/sdf" "as*df" 0
TestGlobPattern C "asd/sdf" "as*" 0
TestGlobPattern C "asd/sdf" "*df" 0
TestGlobPattern C "asd/sdf" "as*dg" NOMATCH
TestGlobPattern C "asdf" "as*df" 0
TestGlobPattern C "asdf" "as*df?" NOMATCH
TestGlobPattern C "asdf" "as*??" 0
TestGlobPattern C "asdf" "a*???" 0
TestGlobPattern C "asdf" "*????" 0
TestGlobPattern C "asdf" "????*" 0
TestGlobPattern C "asdf" "??*?" 0
# B.6 027(C)
TestGlobPattern C "/" "/" 0
TestGlobPattern C "/" "/*" 0
TestGlobPattern C "/" "*/" 0
TestGlobPattern C "/" "/?" NOMATCH
TestGlobPattern C "/" "?/" NOMATCH
TestGlobPattern C "/" "?" 0
TestGlobPattern C "." "?" 0
TestGlobPattern C "/." "??" 0
TestGlobPattern C "/" "[!a-c]" 0
TestGlobPattern C "." "[!a-c]" 0
# B.6 031(C)
TestGlobPattern C "/$" "\\/\\$" 0
TestGlobPattern C "/[" "\\/\\[" 0
TestGlobPattern C "/[" "\\/[" 0
TestGlobPattern C "/[]" "\\/\\[]" 0
# Some home-grown tests.
TestGlobPattern C "foobar" "foo*[abc]z" NOMATCH
TestGlobPattern C "foobaz" "foo*[abc][xyz]" 0
TestGlobPattern C "foobaz" "foo?*[abc][xyz]" 0
TestGlobPattern C "foobaz" "foo?*[abc][x/yz]" 0
TestGlobPattern C "az" "[a-]z" 0
TestGlobPattern C "bz" "[ab-]z" 0
TestGlobPattern C "cz" "[ab-]z" NOMATCH
TestGlobPattern C "-z" "[ab-]z" 0
TestGlobPattern C "az" "[-a]z" 0
TestGlobPattern C "bz" "[-ab]z" 0
TestGlobPattern C "cz" "[-ab]z" NOMATCH
TestGlobPattern C "-z" "[-ab]z" 0
TestGlobPattern C "\\" "[\\\\-a]" 0
TestGlobPattern C "_" "[\\\\-a]" 0
TestGlobPattern C "a" "[\\\\-a]" 0
TestGlobPattern C "-" "[\\\\-a]" NOMATCH
TestGlobPattern C "\\" "[\\]-a]" NOMATCH
TestGlobPattern C "_" "[\\]-a]" 0
TestGlobPattern C "a" "[\\]-a]" 0
TestGlobPattern C "]" "[\\]-a]" 0
TestGlobPattern C "-" "[\\]-a]" NOMATCH
TestGlobPattern C "\\" "[!\\\\-a]" NOMATCH
TestGlobPattern C "_" "[!\\\\-a]" NOMATCH
TestGlobPattern C "a" "[!\\\\-a]" NOMATCH
TestGlobPattern C "-" "[!\\\\-a]" 0
TestGlobPattern C "!" "[\\!-]" 0
TestGlobPattern C "-" "[\\!-]" 0
TestGlobPattern C "\\" "[\\!-]" NOMATCH
TestGlobPattern C "Z" "[Z-\\\\]" 0
TestGlobPattern C "[" "[Z-\\\\]" 0
TestGlobPattern C "\\" "[Z-\\\\]" 0
TestGlobPattern C "-" "[Z-\\\\]" NOMATCH
TestGlobPattern C "Z" "[Z-\\]]" 0
TestGlobPattern C "[" "[Z-\\]]" 0
TestGlobPattern C "\\" "[Z-\\]]" 0
TestGlobPattern C "]" "[Z-\\]]" 0
TestGlobPattern C "-" "[Z-\\]]" NOMATCH
# Following are tests outside the scope of IEEE 2003.2 since they are using
# locales other than the C locale. The main focus of the tests is on the
# handling of ranges and the recognition of character (vs bytes).
TestGlobPattern de_DE.ISO-8859-1 "a" "[a-z]" 0
TestGlobPattern de_DE.ISO-8859-1 "z" "[a-z]" 0
TestGlobPattern de_DE.ISO-8859-1 "ä" "[a-z]" 0
TestGlobPattern de_DE.ISO-8859-1 "ö" "[a-z]" 0
TestGlobPattern de_DE.ISO-8859-1 "ü" "[a-z]" 0
TestGlobPattern de_DE.ISO-8859-1 "A" "[a-z]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "Z" "[a-z]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "Ä" "[a-z]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "Ö" "[a-z]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "Ü" "[a-z]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "a" "[A-Z]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "z" "[A-Z]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "ä" "[A-Z]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "ö" "[A-Z]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "ü" "[A-Z]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "A" "[A-Z]" 0
TestGlobPattern de_DE.ISO-8859-1 "Z" "[A-Z]" 0
TestGlobPattern de_DE.ISO-8859-1 "Ä" "[A-Z]" 0
TestGlobPattern de_DE.ISO-8859-1 "Ö" "[A-Z]" 0
TestGlobPattern de_DE.ISO-8859-1 "Ü" "[A-Z]" 0
TestGlobPattern de_DE.ISO-8859-1 "a" "[[:lower:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "z" "[[:lower:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "ä" "[[:lower:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "ö" "[[:lower:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "ü" "[[:lower:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "A" "[[:lower:]]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "Z" "[[:lower:]]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "Ä" "[[:lower:]]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "Ö" "[[:lower:]]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "Ü" "[[:lower:]]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "a" "[[:upper:]]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "z" "[[:upper:]]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "ä" "[[:upper:]]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "ö" "[[:upper:]]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "ü" "[[:upper:]]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "A" "[[:upper:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "Z" "[[:upper:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "Ä" "[[:upper:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "Ö" "[[:upper:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "Ü" "[[:upper:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "a" "[[:alpha:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "z" "[[:alpha:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "ä" "[[:alpha:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "ö" "[[:alpha:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "ü" "[[:alpha:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "A" "[[:alpha:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "Z" "[[:alpha:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "Ä" "[[:alpha:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "Ö" "[[:alpha:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "Ü" "[[:alpha:]]" 0
TestGlobPattern de_DE.ISO-8859-1 "a" "[[=a=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "â" "[[=a=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "à" "[[=a=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "á" "[[=a=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "ä" "[[=a=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "b" "[[=a=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "c" "[[=a=]b]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "a" "[[=â=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "â" "[[=â=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "à" "[[=â=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "á" "[[=â=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "ä" "[[=â=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "b" "[[=â=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "c" "[[=â=]b]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "a" "[[=à=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "â" "[[=à=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "à" "[[=à=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "á" "[[=à=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "ä" "[[=à=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "b" "[[=à=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "c" "[[=à=]b]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "a" "[[=á=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "â" "[[=á=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "à" "[[=á=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "á" "[[=á=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "ä" "[[=á=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "b" "[[=á=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "c" "[[=á=]b]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "a" "[[=ä=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "â" "[[=ä=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "à" "[[=ä=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "á" "[[=ä=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "ä" "[[=ä=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "b" "[[=ä=]b]" 0
TestGlobPattern de_DE.ISO-8859-1 "c" "[[=ä=]b]" NOMATCH
TestGlobPattern de_DE.ISO-8859-1 "aa" "[[.a.]]a" 0
TestGlobPattern de_DE.ISO-8859-1 "ba" "[[.a.]]a" NOMATCH
# And with a multibyte character set.
TestGlobPattern en_US.UTF-8 "a" "[a-z]" 0
TestGlobPattern en_US.UTF-8 "z" "[a-z]" 0
TestGlobPattern en_US.UTF-8 "A" "[a-z]" NOMATCH
TestGlobPattern en_US.UTF-8 "Z" "[a-z]" NOMATCH
TestGlobPattern en_US.UTF-8 "a" "[A-Z]" NOMATCH
TestGlobPattern en_US.UTF-8 "z" "[A-Z]" NOMATCH
TestGlobPattern en_US.UTF-8 "A" "[A-Z]" 0
TestGlobPattern en_US.UTF-8 "Z" "[A-Z]" 0
TestGlobPattern en_US.UTF-8 "0" "[0-9]" 0
TestGlobPattern en_US.UTF-8 "9" "[0-9]" 0
TestGlobPattern de_DE.UTF-8 "a" "[a-z]" 0
TestGlobPattern de_DE.UTF-8 "z" "[a-z]" 0
TestGlobPattern de_DE.UTF-8 "ä" "[a-z]" 0
TestGlobPattern de_DE.UTF-8 "ö" "[a-z]" 0
TestGlobPattern de_DE.UTF-8 "ü" "[a-z]" 0
TestGlobPattern de_DE.UTF-8 "A" "[a-z]" NOMATCH
TestGlobPattern de_DE.UTF-8 "Z" "[a-z]" NOMATCH
TestGlobPattern de_DE.UTF-8 "Ä" "[a-z]" NOMATCH
TestGlobPattern de_DE.UTF-8 "Ö" "[a-z]" NOMATCH
TestGlobPattern de_DE.UTF-8 "Ü" "[a-z]" NOMATCH
TestGlobPattern de_DE.UTF-8 "a" "[A-Z]" NOMATCH
TestGlobPattern de_DE.UTF-8 "z" "[A-Z]" NOMATCH
TestGlobPattern de_DE.UTF-8 "ä" "[A-Z]" NOMATCH
TestGlobPattern de_DE.UTF-8 "ö" "[A-Z]" NOMATCH
TestGlobPattern de_DE.UTF-8 "ü" "[A-Z]" NOMATCH
TestGlobPattern de_DE.UTF-8 "A" "[A-Z]" 0
TestGlobPattern de_DE.UTF-8 "Z" "[A-Z]" 0
TestGlobPattern de_DE.UTF-8 "Ä" "[A-Z]" 0
TestGlobPattern de_DE.UTF-8 "Ö" "[A-Z]" 0
TestGlobPattern de_DE.UTF-8 "Ü" "[A-Z]" 0
TestGlobPattern de_DE.UTF-8 "a" "[[:lower:]]" 0
TestGlobPattern de_DE.UTF-8 "z" "[[:lower:]]" 0
TestGlobPattern de_DE.UTF-8 "ä" "[[:lower:]]" 0
TestGlobPattern de_DE.UTF-8 "ö" "[[:lower:]]" 0
TestGlobPattern de_DE.UTF-8 "ü" "[[:lower:]]" 0
TestGlobPattern de_DE.UTF-8 "A" "[[:lower:]]" NOMATCH
TestGlobPattern de_DE.UTF-8 "Z" "[[:lower:]]" NOMATCH
TestGlobPattern de_DE.UTF-8 "Ä" "[[:lower:]]" NOMATCH
TestGlobPattern de_DE.UTF-8 "Ö" "[[:lower:]]" NOMATCH
TestGlobPattern de_DE.UTF-8 "Ü" "[[:lower:]]" NOMATCH
TestGlobPattern de_DE.UTF-8 "a" "[[:upper:]]" NOMATCH
TestGlobPattern de_DE.UTF-8 "z" "[[:upper:]]" NOMATCH
TestGlobPattern de_DE.UTF-8 "ä" "[[:upper:]]" NOMATCH
TestGlobPattern de_DE.UTF-8 "ö" "[[:upper:]]" NOMATCH
TestGlobPattern de_DE.UTF-8 "ü" "[[:upper:]]" NOMATCH
TestGlobPattern de_DE.UTF-8 "A" "[[:upper:]]" 0
TestGlobPattern de_DE.UTF-8 "Z" "[[:upper:]]" 0
TestGlobPattern de_DE.UTF-8 "Ä" "[[:upper:]]" 0
TestGlobPattern de_DE.UTF-8 "Ö" "[[:upper:]]" 0
TestGlobPattern de_DE.UTF-8 "Ü" "[[:upper:]]" 0
TestGlobPattern de_DE.UTF-8 "a" "[[:alpha:]]" 0
TestGlobPattern de_DE.UTF-8 "z" "[[:alpha:]]" 0
TestGlobPattern de_DE.UTF-8 "ä" "[[:alpha:]]" 0
TestGlobPattern de_DE.UTF-8 "ö" "[[:alpha:]]" 0
TestGlobPattern de_DE.UTF-8 "ü" "[[:alpha:]]" 0
TestGlobPattern de_DE.UTF-8 "A" "[[:alpha:]]" 0
TestGlobPattern de_DE.UTF-8 "Z" "[[:alpha:]]" 0
TestGlobPattern de_DE.UTF-8 "Ä" "[[:alpha:]]" 0
TestGlobPattern de_DE.UTF-8 "Ö" "[[:alpha:]]" 0
TestGlobPattern de_DE.UTF-8 "Ü" "[[:alpha:]]" 0
TestGlobPattern de_DE.UTF-8 "a" "[[=a=]b]" 0
TestGlobPattern de_DE.UTF-8 "â" "[[=a=]b]" 0
TestGlobPattern de_DE.UTF-8 "à" "[[=a=]b]" 0
TestGlobPattern de_DE.UTF-8 "á" "[[=a=]b]" 0
TestGlobPattern de_DE.UTF-8 "ä" "[[=a=]b]" 0
TestGlobPattern de_DE.UTF-8 "b" "[[=a=]b]" 0
TestGlobPattern de_DE.UTF-8 "c" "[[=a=]b]" NOMATCH
TestGlobPattern de_DE.UTF-8 "a" "[[=â=]b]" 0
TestGlobPattern de_DE.UTF-8 "â" "[[=â=]b]" 0
TestGlobPattern de_DE.UTF-8 "à" "[[=â=]b]" 0
TestGlobPattern de_DE.UTF-8 "á" "[[=â=]b]" 0
TestGlobPattern de_DE.UTF-8 "ä" "[[=â=]b]" 0
TestGlobPattern de_DE.UTF-8 "b" "[[=â=]b]" 0
TestGlobPattern de_DE.UTF-8 "c" "[[=â=]b]" NOMATCH
TestGlobPattern de_DE.UTF-8 "a" "[[=à=]b]" 0
TestGlobPattern de_DE.UTF-8 "â" "[[=à=]b]" 0
TestGlobPattern de_DE.UTF-8 "à" "[[=à=]b]" 0
TestGlobPattern de_DE.UTF-8 "á" "[[=à=]b]" 0
TestGlobPattern de_DE.UTF-8 "ä" "[[=à=]b]" 0
TestGlobPattern de_DE.UTF-8 "b" "[[=à=]b]" 0
TestGlobPattern de_DE.UTF-8 "c" "[[=à=]b]" NOMATCH
TestGlobPattern de_DE.UTF-8 "a" "[[=á=]b]" 0
TestGlobPattern de_DE.UTF-8 "â" "[[=á=]b]" 0
TestGlobPattern de_DE.UTF-8 "à" "[[=á=]b]" 0
TestGlobPattern de_DE.UTF-8 "á" "[[=á=]b]" 0
TestGlobPattern de_DE.UTF-8 "ä" "[[=á=]b]" 0
TestGlobPattern de_DE.UTF-8 "b" "[[=á=]b]" 0
TestGlobPattern de_DE.UTF-8 "c" "[[=á=]b]" NOMATCH
TestGlobPattern de_DE.UTF-8 "a" "[[=ä=]b]" 0
TestGlobPattern de_DE.UTF-8 "â" "[[=ä=]b]" 0
TestGlobPattern de_DE.UTF-8 "à" "[[=ä=]b]" 0
TestGlobPattern de_DE.UTF-8 "á" "[[=ä=]b]" 0
TestGlobPattern de_DE.UTF-8 "ä" "[[=ä=]b]" 0
TestGlobPattern de_DE.UTF-8 "b" "[[=ä=]b]" 0
TestGlobPattern de_DE.UTF-8 "c" "[[=ä=]b]" NOMATCH
TestGlobPattern de_DE.UTF-8 "aa" "[[.a.]]a" 0
TestGlobPattern de_DE.UTF-8 "ba" "[[.a.]]a" NOMATCH
# ksh style matching.
TestGlobPattern C "" "" 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment