[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] for in bash using eval
- Subject: [ale] for in bash using eval
- From: dsj at dsj.net (David S. Jackson)
- Date: Thu, 3 Sep 1998 16:47:40 -0400
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