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