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