> "U.V. Ravindra" wrote: > > > > The final for-loop in the script I supplied to > Roland is obviously mis-written. > > It should be: > > > > typeset -i idx=0 > > > > for arg in ${argtype[*]}; do > > print "${argtype[$idx]} \t ${argname[$idx]} > \t ${argvalue[$idx]}" > > ((idx = idx + 1)) > > done > > Erm... shouldn't this for-loop iterate over each > array element ? If > "yes" the loop should AFAIK look like this: > -- snip -- > integer idx > > for (( idx=0 ; idx < ${!argty...@]} ; idx++ )) ; do > printf "%s \t %s \t %s\n" \ > "${argtype[$idx]}" \ > "${argname[$idx]}" \ > "${argvalue[$idx]}" > snip -- >
The answer to your question is "yes", but the loop I provided does the same thing; it iterates over each array element. Sure, we could do without introducing the extra 'arg' variable, but that's not the point you're making :) By the way, the "wrong" loop in the script originally supplied ALSO produces the expected output, but that should be considered another bug in ksh93. When idx is explicitly declared as integer-typed and argtype is an array containing strings, I would expect the following to fail: typeset -i idx=0 for idx in ${argtype[*]}; do print ${argtype[$idx]} done Why doesn't ksh93 (Version M 1993-12-28 s+) consider this (or even simply: typeset -i idx="junk") an error? -UVR. This message posted from opensolaris.org