]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/posixexp7.sub
Bash-5.2-rc4 release
[thirdparty/bash.git] / tests / posixexp7.sub
CommitLineData
187661b8
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#
d233b485 14# test the effect of quotes on the WORD in the posix pattern removal operators
187661b8 15#
d233b485 16x=notOK
187661b8
CR
17x1=not
18
d233b485 19cat <<EOF
187661b8
CR
201: ${x#$'not'}
212: $'not'
223: ${x#"not"}
234: ${x#'not'}
245: ${x#${x1%'t'}}
d233b485
CR
25EOF
26
27echo "${x#'not'}"
28echo "${x#$'not'}"
29
187661b8
CR
30echo "$'not'"
31echo "${x#"not"}"
32echo "${x#${x1%'t'}}"
33
34cat <<EOF
356: $'not\ttoo\nbad'
36EOF
37
38x=OK$'a\t\'\tb'
39echo OK$'a\t\'\tb'
40echo "$x"
41
42cat <<EOF
437: ${x%$'a\t\'\tb'}
448: ${x#$'a\t\'\tb'}
45EOF
46
47x=OK'a " b'
48
49cat <<EOF
509: ${x#'a " b'}
5110: ${x#$'a " b'}
52EOF
53
54x=notOK
55x1=not
56
57# extquote makes these work
58echo "${x#${$'x1'%$'t'}}"
59cat <<EOF
60${x#${$'x1'%$'t'}}
61EOF
62echo "${x#${$'x1'%'t'}}"
63cat <<EOF
64${x#${$'x1'%'t'}}
65EOF
66
67# syntax errors
68
69echo "${x#${'x1'%'t'}}"
70cat <<EOF
71${x#${'x1'%'t'}}
72EOF
73echo "${x#${'x1'%$'t'}}"
d233b485 74cat <<EOF
187661b8 75${x#${'x1'%$'t'}}
d233b485 76EOF