]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/braces.tests
Bash-5.2-rc4 release
[thirdparty/bash.git] / tests / braces.tests
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 #
14 echo ff{c,b,a}
15 echo f{d,e,f}g
16 echo {l,n,m}xyz
17 echo {abc\,def}
18 echo {abc}
19
20 echo \{a,b,c,d,e}
21 echo {x,y,\{a,b,c}}
22 echo {x\,y,\{abc\},trie}
23
24 echo /usr/{ucb/{ex,edit},lib/{ex,how_ex}}
25
26 echo XXXX\{`echo a b c | tr ' ' ','`\}
27 eval echo XXXX\{`echo a b c | tr ' ' ','`\}
28
29 echo {}
30 echo { }
31 echo }
32 echo {
33 echo abcd{efgh
34
35 echo foo {1,2} bar
36 echo `zecho foo {1,2} bar`
37 echo $(zecho foo {1,2} bar)
38
39 var=baz
40 varx=vx
41 vary=vy
42
43 echo foo{bar,${var}.}
44 echo foo{bar,${var}}
45
46 echo "${var}"{x,y}
47 echo $var{x,y}
48 echo ${var}{x,y}
49
50 unset var varx vary
51
52 # new sequence brace operators
53 echo {1..10}
54
55 # this doesn't work yet
56 echo {0..10,braces}
57 # but this does
58 echo {{0..10},braces}
59 echo x{{0..10},braces}y
60
61 echo {3..3}
62 echo x{3..3}y
63 echo {10..1}
64 echo {10..1}y
65 echo x{10..1}y
66
67 echo {a..f}
68 echo {f..a}
69
70 echo {a..A}
71 echo {A..a}
72
73 echo {f..f}
74
75 # mixes are incorrectly-formed brace expansions
76 echo {1..f}
77 echo {f..1}
78
79 echo 0{1..9} {10..20}
80
81 # do negative numbers work?
82 echo {-1..-10}
83 echo {-20..0}
84
85 # weirdly-formed brace expansions -- fixed in post-bash-3.1
86 echo a-{b{d,e}}-c
87
88 echo a-{bdef-{g,i}-c
89
90 echo {"klklkl"}{1,2,3}
91 echo {"x,x"}
92
93 echo {1..10..2}
94 echo {-1..-10..2}
95 echo {-1..-10..-2}
96
97 echo {10..1..-2}
98 echo {10..1..2}
99
100 echo {1..20..2}
101 echo {1..20..20}
102
103 echo {100..0..5}
104 echo {100..0..-5}
105
106 echo {a..z}
107 echo {a..z..2}
108 echo {z..a..-2}
109
110 # make sure brace expansion handles ints > 2**31 - 1 using intmax_t
111 echo {2147483645..2147483649}
112
113 # unwanted zero-padding -- fixed post-bash-4.0
114 echo {10..0..2}
115 echo {10..0..-2}
116 echo {-50..-0..5}
117
118 # bad
119 echo {1..10.f}
120 echo {1..ff}
121 echo {1..10..ff}
122 echo {1.20..2}
123 echo {1..20..f2}
124 echo {1..20..2f}
125 echo {1..2f..2}
126 echo {1..ff..2}
127 echo {1..ff}
128 echo {1..f}
129 echo {1..0f}
130 echo {1..10f}
131 echo {1..10.f}
132 echo {1..10.f}