Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #11453

Re: Inconsistent arithmetic evaluation of parameters

From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups gnu.bash.bug
Subject Re: Inconsistent arithmetic evaluation of parameters
Date 2015-09-01 16:23 -0400
Message-ID <mailman.355.1441138996.19560.bug-bash@gnu.org> (permalink)
References <61895190-83A6-4D62-B90E-65023D5E966B@gmail.com> <20150901175030.GP4309@eeg.ccf.org> <CANaoh6LNi_YyOOB56ZMR3P8thRSMfoTcDCGyW8S921nVoP1H7Q@mail.gmail.com>

Show all headers | View raw


On Tue, Sep 01, 2015 at 03:13:57PM -0500, Dennis Williamson wrote:
> The version of dash I have handy (0.5.7) has math support which IMHO is
> broken:
> 
> $ foo=bar
> $ bar=5
> $ echo $foo
> bar
> $ echo $((foo))
> dash: 4: Illegal number: bar
> $ echo $(($foo))
> 5
> $ echo $((bar))
> 5
> $ echo $(($bar))
> 5
> 
> Note the inconsistency in support of omitting the inner dollar sign.

$foo is expanded to bar, so the following two lines are always going to
be equivalent:

echo $(($foo))
echo $((bar))

POSIX also specifies (vaguely!!) that $((x)) and $(($x)) are equivalent.

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Inconsistent arithmetic evaluation of parameters Greg Wooledge <wooledg@eeg.ccf.org> - 2015-09-01 16:23 -0400

csiph-web