« Return to Thread: status on $[arith] for eval arith vsl $((arith))??

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

by Chris F.A. Johnson-6 :: Rate this Message:

| View in Thread

On Sat, 7 Apr 2012, Linda Walsh wrote:

> In modifying some released code on my distro,    I ran into the extensive use
> of   $[arith]  as a means for returning arithmetic evaluations of the
> expression.
>
> I vaguely remember something like that from years ago, but never see any
> reference to
> it -- yet it works, and old code seems to rely on it -- and
> "$[(1+2)/3]"  looks cleaner than "$(((1+2)/3))".  So what's up with that?

    At the minor expense of a few extra keystrokes, $(( (1+2) / 3 ))
    looks just as clean, and has the added cachet of being portable.

--
    Chris F.A. Johnson, <http://cfajohnson.com/>
    Author:
    Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
    Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

 « Return to Thread: status on $[arith] for eval arith vsl $((arith))??