bug-bash
[Top][All Lists]
Advanced

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

Re: status on $[arith] for eval arith vsl $((arith))??


From: Linda Walsh
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
Date: Wed, 11 Apr 2012 22:01:12 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666



Greg Wooledge wrote:

On Wed, Apr 11, 2012 at 02:34:01AM -0700, Linda Walsh wrote:
- for ((vl=$((v_level - 1)); $vl > 0; --vl))

The inside of the for ((...)) is already a math context.  You don't need
another $((...)) inside it.

for ((vl = v_level - 1; vl > 0; --vl))

Or is that another "irrelevant detail"?



Um... Why do you think I included it --
I NEVER saw anything like that where [] was used... people
seem to not understand the (()) is arith, but you need $(()) to get
the value out of the insides...



But the examples of use of $(()) are leaning far more toward the perverse side
than simple use of $[]..
a few examples:

- options="$(expr "${options}" : "\(.\{$((${last_option_index}-1))\}\)")"
- YESTERDAY=$(date -r $((`date +%s` - 86400 )) +%d/%m/%Y
- PREGAP=$(($(echo $OFFSETS | cut -f1 -d' ')))

- for ((vl=$((v_level - 1)); $vl > 0; --vl))

---------------------

It's irrelevant to 'function', but not to efficiency or readability.

But hey, gold star for paying attention! ;-)

(those are all examples from various system scripts in /usr...







reply via email to

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