Re: status on $[arith] for eval arith vsl $((arith))??
From:
Maarten Billemont
Subject:
Re: status on $[arith] for eval arith vsl $((arith))??
Date:
Tue, 10 Apr 2012 09:33:34 +0200
On 09 Apr 2012, at 11:46, Linda Walsh wrote:
>
> Like it costs how much? I would **bet** that it cost more code to support
> (()) than to support [] as arith ops .. so if you want my opinion, lets toss
> (())...
> (like that'll happen)...
Just thought I'd add that I personally prefer $((...)) mostly because of
consistency with other syntax. $ is always an indicator of expansion, and
since we have (( ... )) to perform an arithmetic evaluation (on its own as a
statement or in a for etc.), I'm very happy that putting a $ in front of that
is all it takes to expand the result of it. Just like putting a dollar in
front of a subshell construct expands the output of it and putting a dollar in
front of a parameter name expands the contents of it.
If we were to move to $[ ... ], then to keep that consistency, we'd have to
change (( ... )) to [ ... ], and it so happens that this command is already
taken for a different type of test entirely. (Don't give me the spiel about
how [...] is already arithmetic evaluation inside array indices, that's a
different syntax entirely, and perfectly fine - unless you'd prefer to turn it
into arr[ (( ... )) ], which is rather overkill.)