On Mon, Sep 22, 2025 at 10:12:09 -0400, Chet Ramey wrote:
> On 9/22/25 3:24 AM, Gioele Barabucci wrote:
>
> > + for ((i=1; i<=n; i++)); do
> > + "$@"
>
> You need the eval, otherwise something like
>
> repeat 5 v+=f
>
> fails.
On the other hand, often you *don't* want the eval, because then
something like
repeat 5 make CFLAGS="-g -O"
or
file="name has spaces.txt"
repeat 5 scp "$file" "$host:$dir/"
fails. That's why my second offered replacement function uses "$@"
by default but has a -e option to do an eval. I think that's the best
way to go, personally.