Re: Arithmetic expressions and parameters with newlines breaks
From:
Bob Proulx
Subject:
Re: Arithmetic expressions and parameters with newlines breaks
Date:
Mon, 2 Jul 2007 10:08:08 -0600
User-agent:
Mutt/1.5.9i
Jan Schampera wrote:
> Parameters inside arithmetic contexts like $(()) and (()) break
> the expression parsing when they contain a newline
Thank you for your bug report.
> $ foo="12
> > 34"
>
> $ echo $((foo))
> bash: 12
> 34: syntax error in expression (error token is "34")
>
> $ ((foo))
> bash: ((: 12
> 34: syntax error in expression (error token is "34")
That seems like a valid syntax error to me. The newline is not
special. This would be the same as any whitespace.
$ foo="12 34"
$ echo $((foo))
bash: 12 34: syntax error in expression (error token is "34")
What behavior did you expect to see when the evaluated expression
contained whitespace? What would you expect from "12 34"? It is not
a number. It is two numbers. There is no operator between them such
as "12 + 34" or other.
What other result than a syntax error is possible here?
Bob