]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/quote1.sub
Bash-5.2-rc4 release
[thirdparty/bash.git] / tests / quote1.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 # inconsistency with quoted pattern substitution patterns through bash-4.2
15 # fixed in a ksh93-compatible (and Posix-compatible, in general) way
16 # NOT backwards compatible
17
18 test="weferfds'dsfsdf"
19
20 # why does this work, this list was born of frustration, I tried
21 # everything I could think of.
22 echo \'${test//"'"/\'\\\'\'}\'" "
23
24 #but none of the following
25
26 echo "'${test//"'"/}'"
27
28 echo "'${test//"'"/"'\\''"}'"
29
30 printf "%s\n" "'${test//"'"/\'\\'\'}'"
31
32 #echo "'${test//'/}'" # hangs waiting for '
33 #echo "'${test//"'"/'\\''}'" # hangs waiting for '
34
35 unset test
36 test=teststrtest
37 echo "${test//str/"dd dd"}"
38 echo ${test//str/"dd '\''dd"}
39
40 unset test
41 test=teststring
42
43 echo "${test//str/"dddd"}"
44
45 echo ${test//str/"dddd"}
46
47 echo ${test//str/"'"}
48
49 echo "${test//str/"'"}"
50
51 #echo "${test//str/'}" # hangs
52
53 test=test\'string
54 echo "${test//"'"/"'"}"
55
56 x="a'b'c"; echo "${x//\'/\'}"
57
58 printf '%s\n' "foo ${IFS+"b c"} baz"
59
60 # this is where the default behavior differs from posix
61 set -o posix
62 echo "foo ${IFS+'bar} baz"