diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 15:38:56 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 15:38:56 +0000 |
commit | 6c20c8ed2cb9ab69a1a57ccb2b9b79969a808321 (patch) | |
tree | f63ce19d57fad3ac4a15bc26dbfbfa2b834111b5 /tests/iquote.tests | |
parent | Initial commit. (diff) | |
download | bash-6c20c8ed2cb9ab69a1a57ccb2b9b79969a808321.tar.xz bash-6c20c8ed2cb9ab69a1a57ccb2b9b79969a808321.zip |
Adding upstream version 5.2.15.upstream/5.2.15upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/iquote.tests')
-rw-r--r-- | tests/iquote.tests | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/tests/iquote.tests b/tests/iquote.tests new file mode 100644 index 0000000..8411c8a --- /dev/null +++ b/tests/iquote.tests @@ -0,0 +1,158 @@ +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# 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 + +${THIS_SH} ./iquote1.sub |