summaryrefslogtreecommitdiff
path: root/tests/casemod.tests
blob: 3c7ad23feebc8732292358fc45b2f8823274048f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
S1=acknowledgement
S2=oenophile

echo ${S1^}
echo ${S1^^}

echo ${S2^[aeiou]}
echo ${S2^^[aeiou]}

U1=${S1^^}
U2=${S2^^}

echo ${U1,}
echo ${U1,,}

echo ${U2,}
echo ${U2,[AEIOU]}
echo ${U2,,[AEIOU]}

A1=( $S1 $S2 )

echo ${A1[@]^[aeiou]}
echo ${A1[@]^^[aeiou]}

A2=( $U1 $U2 )

echo ${A2[@],[AEIOU]}
echo ${A2[@],,[AEIOU]}

echo ${A2[@],?}
echo ${A2[@],,?}

declare -A AA1 AA2

AA1[ack]=$S1
AA1[oen]=$S2

echo ${AA1[@]^}
echo ${AA1[@]^^}

echo ${AA1[@]^[aeiou]}
echo ${AA1[@]^^[aeiou]}

AA2[ACK]=$U1
AA2[OEN]=$U2

echo ${AA2[@],}
echo ${AA2[@],,}

echo ${AA2[@],[AEIOU]}
echo ${AA2[@],,[AEIOU]}

set -- $S1 $S2

echo ${@^}
echo ${@^^}


echo ${S1^[rstlne]} ${S2^[rstlne]}
echo ${S1^^[rstlne]} ${S2^^[rstlne]}

echo ${@^[rstlne]}
echo ${@^^[rstlne]}

echo ${S1,[rstlne]} ${S2,[rstlne]}
echo ${S1,,[rstlne]} ${S2,,[rstlne]}

echo ${@,[rstlne]}
echo ${@,,[rstlne]}

echo ${@^?}
echo ${@^^?}

# make sure that multiple words in the string are handled as other expansions
TEXT="Be Conservative in what you send and Liberal in what you accept"
TEXT2="be conservative in what you send and liberal in what you accept"

declare -u foo
foo=$TEXT
echo $foo

declare -l bar
bar=$TEXT
echo $bar

declare -c qux
qux=$TEXT
echo $qux
qux=$TEXT2
echo $qux

echo ${TEXT,}
echo ${TEXT,,}

echo ${TEXT^}
echo ${TEXT^^}

echo ${TEXT2^}
echo ${TEXT2^^}