]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/iquote.tests
Bash-4.3 patch 7
[thirdparty/bash.git] / tests / iquote.tests
1 # bug in bash up to and including bash-3.0 (including patches)
2 #
3 # problem is conflict between CTLNUL used internally to denote quoted null
4 # characters and its value (0x7f) appearing in the expansion of a variable
5 #
6 unset x
7 recho "xxx${x}yyy"
8
9 y=$'\177'
10 recho "xxx${y}yyy"
11
12 unset y
13
14 unset undef
15
16 set ""
17 recho ${undef-"x$*y"}
18
19 set $'\177'
20 recho ${undef-"x$*y"}
21
22 shift $#
23
24 f()
25 {
26 recho "-${*-x}-"
27 }
28
29 f ''
30 f $'\177'
31
32 unset -f f
33
34 x=12345
35
36 recho "${x:6:1}"
37
38 x=
39 recho "${x:0:1}"
40
41 y=$'\177'
42 recho "${y:0:1}"
43
44 y=xxx$'\177'yyy
45 recho "${y:3:3}"
46
47 unset x y
48
49 eval tmp=`printf "$'\\\\\x%x'\n" 127`
50 printf "%#1x\n" "'$tmp"
51
52 x=$'\177'
53 printf "%#1x\n" "'$x"
54
55 a=127
56 eval c=\$\'\\$(printf '%o' $a)\'
57 printf "%#1x\n" "'$c"
58
59 recho "$c"
60 recho "$c"@
61 recho @"$c"@
62 recho @"$c"
63
64 recho "$c"
65 recho "$c@"
66 recho "@$c@"
67 recho "@$c"
68
69 unset tmp x a c
70
71 qtest()
72 {
73 recho ${#q} "${q}" ${q}
74 }
75
76 q=$'\x7f'
77 qtest
78
79 q=${q}a
80 qtest
81
82 q=$'\x7fa'
83 qtest
84
85 q="${q}a"
86 qtest
87
88 unset -f qtest
89 unset q
90
91 set -- ''
92 recho "${*:1}"
93 recho ${*:1}
94 recho -${*:1}-
95 recho -"${*:1}"-
96
97 set $'\177'
98 recho "${*:1}"
99 recho "-${*:1}-"
100
101 recho ${*:1}
102 recho -${*:1}-
103
104 shift $#
105
106 DEL=`awk 'END{printf("%c", 0+127)}' </dev/null`
107 T1=a\ $DEL
108 T2="a $DEL"
109 set -- x $(echo $T1|wc -c) $(echo $T2|wc -c); shift
110 L1=$1; L2=$2
111 case "$L1/$L2" in
112 4/4) echo ok;;
113 *) echo CTLNUL bug: L1=$L1, L2=$L2;;
114 esac
115
116 x=$'\177'
117 recho "aaa${x}bbb"
118 recho ccc"${x}"ddd
119 recho eee"$x"fff
120 recho ggg"$(echo $x)"hhh
121
122 x=
123 recho "aaa${x}bbb"
124 recho ccc"${x}"ddd
125 recho eee"$x"fff
126 recho ggg"$(echo $x)"hhh
127
128 set -- $'\177'
129 recho "aaa${1}bbb"
130 recho ccc"${1}"ddd
131 recho eee"$1"fff
132 recho ggg"$(echo $1)"hhh
133
134 set -- ""
135 recho "aaa${1}bbb"
136 recho ccc"${1}"ddd
137 recho eee"$1"fff
138 recho ggg"$(echo $1)"hhh
139
140 recho aaa$'\177'bbb
141 recho ccc"\7f"ddd
142 recho "eee\7ffff"
143 recho ggg"$(echo $'\177')"hhh
144
145 ${THIS_SH} ./iquote1.sub