]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/rhs-exp1.sub
Bash-5.2-rc4 release
[thirdparty/bash.git] / tests / rhs-exp1.sub
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 # fixes for bugs in bash-4.2 regarding empty strings in expand_string_for_rhs
15
16 f=abc
17 recho ${f##""a}
18 recho ${f##"$v"a}
19
20 recho ${f%%""c}
21 recho ${f%%"$v"c}
22
23 recho ${f//""a}
24 recho ${f//"$v"a}
25
26 recho ${f/""a""b/}
27 recho ${f/""c/}
28 recho ${f/"$v"c/}
29
30 unset foo empty
31 foo=aabbcc
32
33 recho ${foo/bb/}
34 recho ${foo/bb/$empty}
35
36 recho ${foo/}
37 recho ${empty/}
38
39 recho ${foo/ }
40 recho ${empty/ }
41 unset foo empty
42
43 S2=oenophile
44
45 recho ${S2^"$v"[aeiou]}
46 recho ${S2^^"$v"[aeiou]}
47
48 recho ${foo:-""}
49 recho ${foo:-""abc}
50
51 recho "${foo:-''}"
52 recho "${foo:-}"
53
54 if [[ $var == "" ]]; then
55 echo good 1
56 fi
57
58 if [[ "$var"X == ""X ]]; then
59 echo good 2
60 fi
61
62 if [ "$var"X == ""X"" ]; then
63 echo good 3
64 fi
65
66 if [ X"" == X ]; then
67 echo good 4
68 fi
69
70 if [[ X"" == X ]]; then
71 echo good 5
72 fi
73
74 case x"" in
75 x) echo 'ok 1'
76 ;;
77 x??) echo 'this would be really odd'
78 ;;
79 x?) echo 'does this prove anything?'
80 echo x""x
81 ;;
82 *) echo 'no match'
83 ;;
84 esac
85
86 if [[ x"" == x ]]; then
87 echo ok 2
88 fi
89
90 if [[ x"\ 1" == x"\ 1" ]]; then
91 echo ok 3
92 else
93 echo bad 3
94 fi
95
96 case x"\ 1" in
97 x"\ 1") echo ok 4 ;;
98 *) echo bad 4;;
99 esac
100
101 if [[ x"\7f" == x"\7f" ]]; then
102 echo ok 5
103 else
104 echo bad 5
105 fi
106
107 case x"\7f" in
108 "x\7f") echo ok 6 ;;
109 *) echo bad 6;;
110 esac
111
112 case x"" in
113 "x\7f") echo CTLNUL 7 ;;
114 x) echo ok 7 ;;
115 *) echo bad 7 ;;
116 esac