diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 15:38:56 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 15:38:56 +0000 |
commit | 6c20c8ed2cb9ab69a1a57ccb2b9b79969a808321 (patch) | |
tree | f63ce19d57fad3ac4a15bc26dbfbfa2b834111b5 /tests/casemod.tests | |
parent | Initial commit. (diff) | |
download | bash-6c20c8ed2cb9ab69a1a57ccb2b9b79969a808321.tar.xz bash-6c20c8ed2cb9ab69a1a57ccb2b9b79969a808321.zip |
Adding upstream version 5.2.15.upstream/5.2.15upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/casemod.tests | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/tests/casemod.tests b/tests/casemod.tests new file mode 100644 index 0000000..56ab20d --- /dev/null +++ b/tests/casemod.tests @@ -0,0 +1,126 @@ +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +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^^} + +M1=${S1^^[aeiou]} +M2=${U2,,[AEIOU]} + +#echo ${M1} ${M1~} +#echo ${M2} ${M2~~} + +declare -l lower=aBcDe +lower+=XyZ +echo $lower + +declare -u upper=aBcDe +upper+=xYZ +echo $upper |