bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] examples/s-f/Bash_aliases: Fix off-by-one error


From: Chet Ramey
Subject: Re: [PATCH v2] examples/s-f/Bash_aliases: Fix off-by-one error
Date: Mon, 22 Sep 2025 10:43:27 -0400
User-agent: Mozilla Thunderbird

On 9/22/25 10:36 AM, Greg Wooledge wrote:
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.

Yeah, that's the other side of using eval. You can quote your way out of
this, but you can't evaluate a variable assignment without using eval.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]