Am 05.05.2012 02:20, schrieb Bill Gradwohl:
Can anyone explain why one pass of this loop works and
then fails.
If it didn't work at all, or worked all the time I could
understand, but working once and then quitting is confusing.
array=(11 12 13 14 15)
variableName='array'
for ((x=0; x<address@hidden; ++x)); do
echo "array[${x}]=${!variableName[$x]}"
done
==================
Produces:
address@hidden 01.ycc# ./tst pass3
array[0]=11
./tst: line 33: !variableName[$x]: unbound variable
--
Bill Gradwohl
AFAIK this syntax ${!variableName[$x]} isn't supported.
I'm guessing the reason the first one worked is because
${!variableName[0]} is a special case because
${!variableName[0]} is a synonym for ${!variableName}
and ${!variableName} is supported.
|