Bash-4.3 distribution sources and documentation
[platform/upstream/bash.git] / tests / quote1.sub
1 # inconsistency with quoted pattern substitution patterns through bash-4.2
2 # fixed in a ksh93-compatible (and Posix-compatible, in general) way
3 # NOT backwards compatible
4
5 test="weferfds'dsfsdf"
6
7 # why does this work, this list was born of frustration, I tried
8 # everything I could think of.
9 echo \'${test//"'"/\'\\\'\'}\'" "
10
11 #but none of the following
12
13 echo "'${test//"'"/}'"
14
15 echo "'${test//"'"/"'\\''"}'"
16
17 echo "'${test//"'"/\'\\'\'}'"
18
19 #echo "'${test//'/}'"   # hangs waiting for '
20 #echo "'${test//"'"/'\\''}'" # hangs waiting for '
21
22 unset test
23 test=teststrtest
24 echo "${test//str/"dd dd"}"
25 echo ${test//str/"dd '\''dd"}
26
27 unset test
28 test=teststring
29
30 echo "${test//str/"dddd"}"
31
32 echo ${test//str/"dddd"}
33
34 echo ${test//str/"'"}
35
36 echo "${test//str/"'"}"
37
38 #echo "${test//str/'}"   # hangs
39
40 test=test\'string
41 echo "${test//"'"/"'"}"
42
43 x="a'b'c"; echo "${x//\'/\'}"
44
45 printf '%s\n' "foo ${IFS+"b   c"} baz"
46
47 # this is where the default behavior differs from posix
48 set -o posix
49 echo "foo ${IFS+'bar} baz"