[Top][All Lists]

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

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

From: Chris F.A. Johnson
Subject: Re: status on $[arith] for eval arith vsl $((arith))??
Date: Sun, 8 Apr 2012 15:11:45 -0400 (EDT)
User-agent: Alpine 2.00 (LMD 1167 2008-08-23)

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/>
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

reply via email to

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