aboutsummaryrefslogtreecommitdiffstats
path: root/tests/array.tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/array.tests')
-rw-r--r--tests/array.tests64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/array.tests b/tests/array.tests
index 4f5d830..4a735d8 100644
--- a/tests/array.tests
+++ b/tests/array.tests
@@ -236,7 +236,12 @@ echo "value = ${barray[*]}"
set -u
( echo ${#narray[4]} )
+${THIS_SH} ./array1.sub
+${THIS_SH} ./array2.sub
+
# some old bugs and ksh93 compatibility tests
+${THIS_SH} ./array3.sub
+
set +u
cd /tmp
@@ -332,3 +337,62 @@ echo ${av[@]: -1:2}
echo out-of-range offset
echo ${av[@]:12}
+
+# parsing problems and other inconsistencies not fixed until post bash-3.0
+unset x
+declare -a x=(')' $$)
+[ ${x[1]} -eq $$ ] || echo bad
+
+unset x
+declare -a x=(a b c d e)
+echo ${x[4]}
+
+z=([1]=one [4]=four [7]=seven [10]=ten)
+
+echo ${#z[@]}
+
+echo ${!z[@]}
+
+unset x
+declare -a x=(a \'b c\')
+
+echo "${x[1]}"
+
+unset x
+declare -a x=(a 'b c')
+
+echo "${x[1]}"
+
+unset x
+declare -a x=($0)
+[ "${x[@]}" = $0 ] || echo double expansion of \$0
+declare -a x=(\$0)
+echo "${x[@]}"
+
+: ${TMPDIR:=/tmp}
+
+mkdir $TMPDIR/bash-test-$$
+cd $TMPDIR/bash-test-$$
+
+trap "cd / ; rm -rf $TMPDIR/bash-test-$$" 0 1 2 3 6 15
+
+touch '[3]=abcde'
+
+touch r s t u v
+
+declare -a x=(*)
+
+echo ${x[3]}
+echo ${x[@]}
+
+unset x
+x=(a b c d e)
+
+echo ${x[*]: -1}
+
+unset x[4]
+unset x[2]
+
+x[9]='9'
+
+echo ${x[*]: -1}