[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Some incorrect behaviour for BASH arrays
From: |
Victor Pasko |
Subject: |
Some incorrect behaviour for BASH arrays |
Date: |
Thu, 31 Aug 2023 01:12:48 +0700 |
Hi,
On my Win-7 64-bit using Cygwin
*% bash --version*GNU bash, version 5.2.15(3)-release (x86_64-pc-cygwin)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
*% echo LANG=$LANG; echo LC_ALL=$LC_ALL*LANG=
LC_ALL=
Attached please find bug.bash to reproduce incorrect BASH behaviour for
BASH arrays
and look at ways to run it
*% . bug.bash no*
VERBOSE=no
GOOD variants of sed
string=Bb12345678 QSTRING=10
result=Bb12345678 size=10 Bb12345678
string=bB123-4567-8 QSTRING=12
result=bB123\-4567\-8 size=14 bB123\-4567\-8
BAD variants of sed
string=Bb12345678 QSTRING=10
result=B size=1 B
string=bB123-4567-8 QSTRING=12
result=b size=1 b
GOOD variant of rev
string=123456789 QSTRING=9
result=987654321 size=9
BAD variant of rev
string=123456789 QSTRING=9
result=9 size=1
*% . bug.bash yes*
VERBOSE=yes
GOOD variants of sed
string=Bb12345678 QSTRING=10
DEBUG i-symbol=B
DEBUG i-symbol=b
DEBUG i-symbol=1
DEBUG i-symbol=2
DEBUG i-symbol=3
DEBUG i-symbol=4
DEBUG i-symbol=5
DEBUG i-symbol=6
DEBUG i-symbol=7
DEBUG i-symbol=8
result=Bb12345678 size=10 Bb12345678
string=bB123-4567-8 QSTRING=12
DEBUG i-symbol=b
DEBUG i-symbol=B
DEBUG i-symbol=1
DEBUG i-symbol=2
DEBUG i-symbol=3
DEBUG i-symbol=-
DEBUG i-symbol=4
DEBUG i-symbol=5
DEBUG i-symbol=6
DEBUG i-symbol=7
DEBUG i-symbol=-
DEBUG i-symbol=8
result=bB123\-4567\-8 size=14 bB123\-4567\-8
BAD variants of sed
string=Bb12345678 QSTRING=10
DEBUG i-symbol=B
DEBUG i-symbol=b
DEBUG i-symbol=1
DEBUG i-symbol=2
DEBUG i-symbol=3
DEBUG i-symbol=4
DEBUG i-symbol=5
DEBUG i-symbol=6
DEBUG i-symbol=7
DEBUG i-symbol=8
result=B size=1 B
string=bB123-4567-8 QSTRING=12
DEBUG i-symbol=b
DEBUG i-symbol=B
DEBUG i-symbol=1
DEBUG i-symbol=2
DEBUG i-symbol=3
DEBUG i-symbol=-
DEBUG i-symbol=4
DEBUG i-symbol=5
DEBUG i-symbol=6
DEBUG i-symbol=7
DEBUG i-symbol=-
DEBUG i-symbol=8
result=b size=1 b
GOOD variant of rev
string=123456789 QSTRING=9
DEBUG i-symbol=9
DEBUG i-symbol=8
DEBUG i-symbol=7
DEBUG i-symbol=6
DEBUG i-symbol=5
DEBUG i-symbol=4
DEBUG i-symbol=3
DEBUG i-symbol=2
DEBUG i-symbol=1
result=987654321 size=9
BAD variant of rev
string=123456789 QSTRING=9
DEBUG i-symbol=9
DEBUG i-symbol=8
DEBUG i-symbol=7
DEBUG i-symbol=6
DEBUG i-symbol=5
DEBUG i-symbol=4
DEBUG i-symbol=3
DEBUG i-symbol=2
DEBUG i-symbol=1
XXX-break i=9 result=9 size=1
result=9 size=1
*% BTW The following lines in bug.bash are just for researching and
unneeded at all*
if [ $i -ge $QSTRING ] ; then
echo "XXX-break i=$i result=$RESULT size=${#RESULT}"
break # XXX
fi
*% ls -al bug.bash*
-rw-r--r--+ 1 victor None 2104 Aug 31 00:55 bug.bash
--
-- PSK
bug.bash
Description: Binary data
- Some incorrect behaviour for BASH arrays,
Victor Pasko <=