[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: expr: expr 3 \* 4 -> expr 3 x 4 ?
From: |
Eric Blake |
Subject: |
Re: expr: expr 3 \* 4 -> expr 3 x 4 ? |
Date: |
Wed, 01 Aug 2012 08:13:22 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 |
On 08/01/2012 07:49 AM, Jari Vuoksenranta wrote:
> Would it break anything if "*" was replaced with a "x" (on command line ONLY)?
> I mostly use expr in such easy div / mul tasks...
I suppose such an extension would be okay, however, how would you
reliably know whether you have a new enough coreutils providing the
extension, when you might as well just stick with the syntax
standardized by POSIX?
>
> "expr (GNU coreutils) 8.15 Packaged by Cygwin (8.15-1)"
Furthermore, why are you using 'expr' in the first place? Spawning a
new process is expensive, and it is much faster to use shell built-in
arithmetic (also guaranteed by POSIX and present on cygwin). Change
your script from:
expr 3 \* 4
to
echo $((3 * 4))
for faster execution, and so that you no longer have to escape the *,
all without proposing any changes to expr.
--
Eric Blake address@hidden +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature