aboutsummaryrefslogtreecommitdiffstats
path: root/tests/iquote.tests
blob: a2cdf4f71f2d3f4f29faf55c3b9cbd037ae9563f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# bug in bash up to and including bash-3.0 (including patches)
#
# problem is conflict between CTLNUL used internally to denote quoted null
# characters and its value (0x7f) appearing in the expansion of a variable
#
unset x
recho "xxx${x}yyy"

y=$'\177'
recho "xxx${y}yyy"

unset y

unset undef

set ""
recho ${undef-"x$*y"}

set $'\177'
recho ${undef-"x$*y"}

shift $#

f()
{
	recho "-${*-x}-"
}

f ''
f $'\177'

unset -f f

x=12345

recho "${x:6:1}"

x=
recho "${x:0:1}"

y=$'\177'
recho "${y:0:1}"

y=xxx$'\177'yyy
recho "${y:3:3}"

unset x y

eval tmp=`printf "$'\\\\\x%x'\n" 127`
printf "%#1x\n" "'$tmp"

x=$'\177'
printf "%#1x\n" "'$x"

a=127
eval c=\$\'\\$(printf '%o' $a)\'
printf "%#1x\n" "'$c"

recho "$c"
recho "$c"@
recho @"$c"@
recho @"$c"

recho "$c"
recho "$c@"
recho "@$c@"
recho "@$c"

unset tmp x a c

qtest()
{
	recho ${#q} "${q}" ${q}
}

q=$'\x7f'
qtest

q=${q}a
qtest

q=$'\x7fa'
qtest

q="${q}a"
qtest

unset -f qtest
unset q

set -- ''
recho "${*:1}"
recho  ${*:1}
recho  -${*:1}-
recho  -"${*:1}"-

set $'\177'
recho "${*:1}"
recho "-${*:1}-"

recho  ${*:1}
recho -${*:1}-

shift $#

DEL=`awk 'END{printf("%c", 0+127)}' </dev/null`
T1=a\ $DEL
T2="a $DEL"
set -- x $(echo $T1|wc -c) $(echo $T2|wc -c); shift
L1=$1; L2=$2
case "$L1/$L2" in
4/4) echo ok;;
*) echo CTLNUL bug: L1=$L1, L2=$L2;;
esac

x=$'\177'
recho "aaa${x}bbb"
recho ccc"${x}"ddd
recho eee"$x"fff
recho ggg"$(echo $x)"hhh

x=
recho "aaa${x}bbb"
recho ccc"${x}"ddd
recho eee"$x"fff
recho ggg"$(echo $x)"hhh

set -- $'\177'
recho "aaa${1}bbb"
recho ccc"${1}"ddd
recho eee"$1"fff
recho ggg"$(echo $1)"hhh

set -- ""
recho "aaa${1}bbb"
recho ccc"${1}"ddd
recho eee"$1"fff
recho ggg"$(echo $1)"hhh

recho aaa$'\177'bbb
recho ccc""ddd
recho "eeefff"
recho ggg"$(echo $'\177')"hhh