]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/casemod.tests
bash-5.1 distribution sources and documentation
[thirdparty/bash.git] / tests / casemod.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#
3185942a
JA
14S1=acknowledgement
15S2=oenophile
16
17echo ${S1^}
18echo ${S1^^}
19
20echo ${S2^[aeiou]}
21echo ${S2^^[aeiou]}
22
23U1=${S1^^}
24U2=${S2^^}
25
26echo ${U1,}
27echo ${U1,,}
28
29echo ${U2,}
30echo ${U2,[AEIOU]}
31echo ${U2,,[AEIOU]}
32
33A1=( $S1 $S2 )
34
35echo ${A1[@]^[aeiou]}
36echo ${A1[@]^^[aeiou]}
37
38A2=( $U1 $U2 )
39
40echo ${A2[@],[AEIOU]}
41echo ${A2[@],,[AEIOU]}
42
43echo ${A2[@],?}
44echo ${A2[@],,?}
45
46declare -A AA1 AA2
47
48AA1[ack]=$S1
49AA1[oen]=$S2
50
51echo ${AA1[@]^}
52echo ${AA1[@]^^}
53
54echo ${AA1[@]^[aeiou]}
55echo ${AA1[@]^^[aeiou]}
56
57AA2[ACK]=$U1
58AA2[OEN]=$U2
59
60echo ${AA2[@],}
61echo ${AA2[@],,}
62
63echo ${AA2[@],[AEIOU]}
64echo ${AA2[@],,[AEIOU]}
65
66set -- $S1 $S2
67
68echo ${@^}
69echo ${@^^}
70
71
72echo ${S1^[rstlne]} ${S2^[rstlne]}
73echo ${S1^^[rstlne]} ${S2^^[rstlne]}
74
75echo ${@^[rstlne]}
76echo ${@^^[rstlne]}
77
78echo ${S1,[rstlne]} ${S2,[rstlne]}
79echo ${S1,,[rstlne]} ${S2,,[rstlne]}
80
81echo ${@,[rstlne]}
82echo ${@,,[rstlne]}
83
84echo ${@^?}
85echo ${@^^?}
17345e5a
JA
86
87# make sure that multiple words in the string are handled as other expansions
88TEXT="Be Conservative in what you send and Liberal in what you accept"
89TEXT2="be conservative in what you send and liberal in what you accept"
90
91declare -u foo
92foo=$TEXT
93echo $foo
94
95declare -l bar
96bar=$TEXT
97echo $bar
98
99declare -c qux
100qux=$TEXT
101echo $qux
102qux=$TEXT2
103echo $qux
104
105echo ${TEXT,}
106echo ${TEXT,,}
107
108echo ${TEXT^}
109echo ${TEXT^^}
110
111echo ${TEXT2^}
112echo ${TEXT2^^}
a0c0a00f
CR
113
114M1=${S1^^[aeiou]}
115M2=${U2,,[AEIOU]}
116
8868edaf
CR
117#echo ${M1} ${M1~}
118#echo ${M2} ${M2~~}
a0c0a00f
CR
119
120declare -l lower=aBcDe
121lower+=XyZ
122echo $lower
123
124declare -u upper=aBcDe
125upper+=xYZ
126echo $upper