]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/posixexp7.sub
Bash-5.2-rc4 release
[thirdparty/bash.git] / tests / posixexp7.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 # test the effect of quotes on the WORD in the posix pattern removal operators
15 #
16 x=notOK
17 x1=not
18
19 cat <<EOF
20 1: ${x#$'not'}
21 2: $'not'
22 3: ${x#"not"}
23 4: ${x#'not'}
24 5: ${x#${x1%'t'}}
25 EOF
26
27 echo "${x#'not'}"
28 echo "${x#$'not'}"
29
30 echo "$'not'"
31 echo "${x#"not"}"
32 echo "${x#${x1%'t'}}"
33
34 cat <<EOF
35 6: $'not\ttoo\nbad'
36 EOF
37
38 x=OK$'a\t\'\tb'
39 echo OK$'a\t\'\tb'
40 echo "$x"
41
42 cat <<EOF
43 7: ${x%$'a\t\'\tb'}
44 8: ${x#$'a\t\'\tb'}
45 EOF
46
47 x=OK'a " b'
48
49 cat <<EOF
50 9: ${x#'a " b'}
51 10: ${x#$'a " b'}
52 EOF
53
54 x=notOK
55 x1=not
56
57 # extquote makes these work
58 echo "${x#${$'x1'%$'t'}}"
59 cat <<EOF
60 ${x#${$'x1'%$'t'}}
61 EOF
62 echo "${x#${$'x1'%'t'}}"
63 cat <<EOF
64 ${x#${$'x1'%'t'}}
65 EOF
66
67 # syntax errors
68
69 echo "${x#${'x1'%'t'}}"
70 cat <<EOF
71 ${x#${'x1'%'t'}}
72 EOF
73 echo "${x#${'x1'%$'t'}}"
74 cat <<EOF
75 ${x#${'x1'%$'t'}}
76 EOF