#!/bin/bash
arrck=
arrrlt=
if true; then
arrck+=("1")
arrrlt+=("one")
else
echo "something"
fi
for i in ${!arrck[*]}
do
echo "${arrck[i]} is ${arrrlt[i]}"
done
output 1--
is
1 is one
output 2--tracing on
./Building_block.sh
+ arrck=
+ arrrlt=
+ true
+ arrck+=("1")
+ arrrlt+=("one")
+ for i in '${!arrck[*]}'
+ echo ' is '
is
+ for i in '${!arrck[*]}'
+ echo '1 is one'
1 is one
Why is the loop running with no value assigned to i ? i can say it tried to execute echo "${arrck[]} is ${arrrlt[]}" and picking the blank space as value.
echo ${!arrck[@]}==>0 10for the 2 arraysarrckandarrrlt