init version.
[bush.git] / tests / quote / iquote / iquote.tests
blob10902f201f570c5d22d3d8bf094d9abe247a4e76
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.
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.
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/>.
14 # bug in bush up to and including bush-3.0 (including patches)
16 # problem is conflict between CTLNUL used internally to denote quoted null
17 # characters and its value (0x7f) appearing in the expansion of a variable
19 unset x
20 recho "xxx${x}yyy"
22 y=$'\177'
23 recho "xxx${y}yyy"
25 unset y
27 unset undef
29 set ""
30 recho ${undef-"x$*y"}
32 set $'\177'
33 recho ${undef-"x$*y"}
35 shift $#
37 f()
39         recho "-${*-x}-"
42 f ''
43 f $'\177'
45 unset -f f
47 x=12345
49 recho "${x:6:1}"
52 recho "${x:0:1}"
54 y=$'\177'
55 recho "${y:0:1}"
57 y=xxx$'\177'yyy
58 recho "${y:3:3}"
60 unset x y
62 eval tmp=`printf "$'\\\\\x%x'\n" 127`
63 printf "%#1x\n" "'$tmp"
65 x=$'\177'
66 printf "%#1x\n" "'$x"
68 a=127
69 eval c=\$\'\\$(printf '%o' $a)\'
70 printf "%#1x\n" "'$c"
72 recho "$c"
73 recho "$c"@
74 recho @"$c"@
75 recho @"$c"
77 recho "$c"
78 recho "$c@"
79 recho "@$c@"
80 recho "@$c"
82 unset tmp x a c
84 qtest()
86         recho ${#q} "${q}" ${q}
89 q=$'\x7f'
90 qtest
92 q=${q}a
93 qtest
95 q=$'\x7fa'
96 qtest
98 q="${q}a"
99 qtest
101 unset -f qtest
102 unset q
104 set -- ''
105 recho "${*:1}"
106 recho  ${*:1}
107 recho  -${*:1}-
108 recho  -"${*:1}"-
110 set $'\177'
111 recho "${*:1}"
112 recho "-${*:1}-"
114 recho  ${*:1}
115 recho -${*:1}-
117 shift $#
119 DEL=`awk 'END{printf("%c", 0+127)}' </dev/null`
120 T1=a\ $DEL
121 T2="a $DEL"
122 set -- x $(echo $T1|wc -c) $(echo $T2|wc -c); shift
123 L1=$1; L2=$2
124 case "$L1/$L2" in
125 4/4) echo ok;;
126 *) echo CTLNUL bug: L1=$L1, L2=$L2;;
127 esac
129 x=$'\177'
130 recho "aaa${x}bbb"
131 recho ccc"${x}"ddd
132 recho eee"$x"fff
133 recho ggg"$(echo $x)"hhh
136 recho "aaa${x}bbb"
137 recho ccc"${x}"ddd
138 recho eee"$x"fff
139 recho ggg"$(echo $x)"hhh
141 set -- $'\177'
142 recho "aaa${1}bbb"
143 recho ccc"${1}"ddd
144 recho eee"$1"fff
145 recho ggg"$(echo $1)"hhh
147 set -- ""
148 recho "aaa${1}bbb"
149 recho ccc"${1}"ddd
150 recho eee"$1"fff
151 recho ggg"$(echo $1)"hhh
153 recho aaa$'\177'bbb
154 recho ccc"\x7f"ddd
155 recho "eee\x7ffff"
156 recho ggg"$(echo $'\177')"hhh
158 ${THIS_SH} ./iquote1.sub