]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/extglob2.tests
Bash-5.2-rc4 release
[thirdparty/bash.git] / tests / extglob2.tests
CommitLineData
8868edaf
CR
1# This program is free software: you can redistribute it and/or modify
2# it under the terms of the GNU General Public License as published by
3# the Free Software Foundation, either version 3 of the License, or
4# (at your option) any later version.
5#
6# This program is distributed in the hope that it will be useful,
7# but WITHOUT ANY WARRANTY; without even the implied warranty of
8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9# GNU General Public License for more details.
10#
11# You should have received a copy of the GNU General Public License
12# along with this program. If not, see <http://www.gnu.org/licenses/>.
13#
bb70624e
JA
14#
15# More ksh-like extended globbing tests, cribbed from zsh-3.1.5
16#
17shopt -s extglob
18
19failed=0
20while read res str pat; do
21 [[ $res = '#' ]] && continue
22 [[ $str = ${pat} ]]
23 ts=$?
24 [[ $1 = -q ]] || echo "$ts: [[ $str = $pat ]]"
25 if [[ ( $ts -gt 0 && $res = t) || ($ts -eq 0 && $res = f) ]]; then
26 echo "Test failed: [[ $str = $pat ]]"
27 (( failed += 1 ))
28 fi
29done <<EOT
30t fofo *(f*(o))
31t ffo *(f*(o))
32t foooofo *(f*(o))
33t foooofof *(f*(o))
34t fooofoofofooo *(f*(o))
35f foooofof *(f+(o))
36f xfoooofof *(f*(o))
37f foooofofx *(f*(o))
38t ofxoofxo *(*(of*(o)x)o)
39f ofooofoofofooo *(f*(o))
40t foooxfooxfoxfooox *(f*(o)x)
41f foooxfooxofoxfooox *(f*(o)x)
42t foooxfooxfxfooox *(f*(o)x)
43t ofxoofxo *(*(of*(o)x)o)
44t ofoooxoofxo *(*(of*(o)x)o)
45t ofoooxoofxoofoooxoofxo *(*(of*(o)x)o)
46t ofoooxoofxoofoooxoofxoo *(*(of*(o)x)o)
47f ofoooxoofxoofoooxoofxofo *(*(of*(o)x)o)
48t ofoooxoofxoofoooxoofxooofxofxo *(*(of*(o)x)o)
49t aac *(@(a))a@(c)
50t ac *(@(a))a@(c)
51f c *(@(a))a@(c)
52t aaac *(@(a))a@(c)
53f baaac *(@(a))a@(c)
54t abcd ?@(a|b)*@(c)d
55t abcd @(ab|a*@(b))*(c)d
56t acd @(ab|a*(b))*(c)d
57t abbcd @(ab|a*(b))*(c)d
58t effgz @(b+(c)d|e*(f)g?|?(h)i@(j|k))
59t efgz @(b+(c)d|e*(f)g?|?(h)i@(j|k))
60t egz @(b+(c)d|e*(f)g?|?(h)i@(j|k))
61t egzefffgzbcdij *(b+(c)d|e*(f)g?|?(h)i@(j|k))
62f egz @(b+(c)d|e+(f)g?|?(h)i@(j|k))
63t ofoofo *(of+(o))
64t oxfoxoxfox *(oxf+(ox))
65f oxfoxfox *(oxf+(ox))
66t ofoofo *(of+(o)|f)
67# The following is supposed to match only as fo+ofo+ofo
68t foofoofo @(foo|f|fo)*(f|of+(o))
69t oofooofo *(of|oof+(o))
70t fffooofoooooffoofffooofff *(*(f)*(o))
71# The following tests backtracking in alternation matches
72t fofoofoofofoo *(fo|foo)
73# Exclusion
74t foo !(x)
75t foo !(x)*
76f foo !(foo)
77t foo !(foo)*
78t foobar !(foo)
79t foobar !(foo)*
80t moo.cow !(*.*).!(*.*)
81f mad.moo.cow !(*.*).!(*.*)
82f mucca.pazza mu!(*(c))?.pa!(*(z))?
83t fff !(f)
84t fff *(!(f))
85t fff +(!(f))
86t ooo !(f)
87t ooo *(!(f))
88t ooo +(!(f))
89t foo !(f)
90t foo *(!(f))
91t foo +(!(f))
92f f !(f)
93f f *(!(f))
94f f +(!(f))
95t foot @(!(z*)|*x)
96f zoot @(!(z*)|*x)
97t foox @(!(z*)|*x)
98t zoox @(!(z*)|*x)
99t foo *(!(foo))
100f foob !(foo)b*
101t foobb !(foo)b*
102EOT
103echo "$failed tests failed."