Roland Mainz
2013-05-27 13:08:29 UTC
Hi!
----
The following example...
-- snip --
$ ksh -c 'typeset -a ar=( 2 3 4 ) ; function fn { nameref n=$1 ; print
-- "$n" ; } ; function main { integer i ; for ((i=0 ; i < ${#ar[@]} ;
)) ; do fn ar[i++] ; done ; } ; main ; true'
-- snip --
... should AFAIK print...
--- snip --
2
3
4
-- snip --
... but ast-ksh.2013-05-24 runs in an endless loop (warning (mostly
for myself): Any test module should have a 2nd integer aborting the
endless loop) printing newlines...
The workaround is to replace the ar[i++] with ar[$((i++))], e.g. ...
-- snip --
$ ksh -c 'typeset -a ar=( 2 3 4 ) ; function fn { nameref n=$1 ; print
-- "$n" ; } ; function main { integer i ; for ((i=0 ; i < ${#ar[@]} ;
)) ; do fn ar[$((i++))] ; done ; } ; main ; true'
2
3
4
-- snip --
... so that the nameref only gets a "static" string as index... the
only issue is that this requires an internal integer-to-string
conversion which is IMO unneccesary...
----
Bye,
Roland
----
The following example...
-- snip --
$ ksh -c 'typeset -a ar=( 2 3 4 ) ; function fn { nameref n=$1 ; print
-- "$n" ; } ; function main { integer i ; for ((i=0 ; i < ${#ar[@]} ;
)) ; do fn ar[i++] ; done ; } ; main ; true'
-- snip --
... should AFAIK print...
--- snip --
2
3
4
-- snip --
... but ast-ksh.2013-05-24 runs in an endless loop (warning (mostly
for myself): Any test module should have a 2nd integer aborting the
endless loop) printing newlines...
The workaround is to replace the ar[i++] with ar[$((i++))], e.g. ...
-- snip --
$ ksh -c 'typeset -a ar=( 2 3 4 ) ; function fn { nameref n=$1 ; print
-- "$n" ; } ; function main { integer i ; for ((i=0 ; i < ${#ar[@]} ;
)) ; do fn ar[$((i++))] ; done ; } ; main ; true'
2
3
4
-- snip --
... so that the nameref only gets a "static" string as index... the
only issue is that this requires an internal integer-to-string
conversion which is IMO unneccesary...
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)