[ale] for in bash using eval
David S. Jackson
dsj at dsj.net
Thu Sep 3 16:47:40 EDT 1998
Thus spake Michelangelo Grigni (mic at mathcs.emory.edu):
> How about this (a function rather than script, but that
> could be changed):
>
> # A pascal-style for loop (no foolin with that counter)
>
> function loop
> {
> local varname="$1" counter="$2" upper="$3"
> shift 3
> while [ $counter -le $upper ]
> do
> eval "$varname=$counter; $@"
> counter=$(($counter+1))
> done
> }
>
> loop i 1 10 echo \$i
GREAT! :-)
I think that's it! If you don't mind, I'm gonna email OReilly and see
if this is what the author had in mind. I think this is it all right.
:-)
Great work!
--
David S. Jackson http://www.dsj.net
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"It is a greater compliment to be trusted than to be loved."
--George Macdonald
More information about the Ale
mailing list