]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/nquote.tests
bash-5.1-alpha release
[thirdparty/bash.git] / tests / nquote.tests
CommitLineData
712f80b0
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#
ccc6cda3
JA
14expect()
15{
16 echo expect "$@"
17}
18
19expect '<^J^J^J>'
20recho $'\n\n\n'
21
bb70624e
JA
22expect '<++^J++>'
23f=$'\n'
24recho "++$f++"
25unset f
26
ccc6cda3
JA
27z1=$''
28expect '<>'
29recho "$z1"
30
31ZIFS=$'\n'$'\t'$' '
32
33expect '<^J^I >'
34recho "$ZIFS"
35
36expect '<abc>'
37recho $'abc'
38
39expect '<^M^[^Gabc>'
40recho $'\r\e\aabc'
41
42D=$"hello"," "$"world"
43
44expect '<hello,> <world>'
45recho $D
46
47expect '<hello, world>'
48recho "$D"
49
50D=$""
51expect '<>'
52recho "$D"
53
54world=chet
55
56expect '<$hello, world>'
57recho \$"hello, world"
58
59expect '<hello, $world>'
60recho $"hello, \$world"
61
62expect '<hello, "world">'
63recho $"hello, \"world\""
64
65expect '<hello, $"world">'
66recho $"hello"', $"world"'
67
68expect '<hello, $"world">'
69recho $'hello, $"world"'
70
71expect '<$hello, chet>'
72recho \$"hello, $world"
73
74expect '<hello, chet>'
75recho $"hello, $world"
d166f048
JA
76
77z=$'\v\f\a\b'
78case "$z" in
79$'\v\f\a\b') echo ok;;
80*) echo bad;;
81esac
bb70624e
JA
82
83# Dave Korn says this should be allowed and echo 'abcd'
84echo $'\'abcd\''
85
86# printf translates \' to ' ...
87printf "\'abcd\'\n"
88
89# but echo -e doesn't
90echo -e "\'abcd\'"
91echo -e "\\'abcd\\'"
92
95732b49 93# and what do we do about unrecognized escape sequences?
bb70624e 94
95732b49
JA
95shopt -s xpg_echo
96
97recho $'A\CB'
98
99recho "A\CB"
100
101cde=c
102recho $'ab$cde'
103
104printf "%b\n" 'A\CB'
105printf 'A\CB\n'
106
107echo 'A\CB'
108
109world=chet
110
111recho $'hello, $"world"'
112recho $'hello, \$"world"'
113recho $'hello, $\"world"'
114
115recho "hello, $"world""
0628567a
JA
116
117# ansi quoting inside double-quoted command subst - bash-3.1 bug
118echo $(set -- $'a b'; echo $#)
119echo "$(set -- $'a b'; echo $#)"
120
121echo "$(echo $';foo')"
122
123args ()
124{
125 for a in "$@";do echo "'$a'";done
126}
127unset mytab
128recho "${mytab:-$'\t'}"
129recho "$( args $'A\tB' )"
0001803f
CR
130
131${THIS_SH} ./nquote1.sub
ac50fbac 132${THIS_SH} ./nquote2.sub
a0c0a00f 133${THIS_SH} ./nquote3.sub