Jan Schampera wrote:
> Well, I guess intuitively expected that it evaluates to 0, like for
> example:
> 
> $ test=string
> $ echo $((test))
> 0

In that case it is like the 'atoi(3)' routine.  A non-numeric has no
number value and is evaluated to be zero.  A single zero is a valid
arithmetic expression.

  $ echo $((0))
  0

But two numbers is a different case.

  $ echo $((0 0))
  sh: line 1: 0 0: syntax error in expression (error token is "0")

This is the same in bash as in other languages too.  They are all very
similar on this point.

> But I just made some experiments (which I should have done before) and
> read the manual again a bit closer: In this example I really reference
> the variable "string" (as designated operand) which is unset/null and
> thus evaluates to 0.
> 
> I also saw this can be done in any depth.

Yes.  Well, all's well that ends well.  :-)

> So, excuse my wrong interpretion of the manual (maybe that needs to be
> marked extra by a sentence or a half in manual). It's definitely not a
> bug (it is - between screen and chair!).

Suggestions for improvements to the documentation are always
appreciated.

> Best regards and thanks again for quick reply,

Good luck!
Bob


_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash

Reply via email to