Re: Question about arithmetic expression grammar

2016-10-15 Thread Chet Ramey
On 10/10/16 9:57 AM, Stephane Chazelas wrote: > Now, if we look at the C spec, the way +++ is parsed is down to > tokenisation that will also go for the longest operator first. > > There --test+++3 would be tokenised as -- test ++ + 3 which > would lead to a syntax error as test++ isn't an lvalue

Re: Question about arithmetic expression grammar

2016-10-10 Thread Stephane Chazelas
2016-10-08 17:33:00 +0200, Conrad Hoffmann: [...] > $ TEST=5; echo $((--TEST+++3)) # outputs 7 > > However, due to the documented operator precedence, I would have > expected that expression to be equal to: > > $ TEST=5; echo $((--(TEST++)+3)) # outputs 8 > > Instead, though, it seems to be

Question about arithmetic expression grammar

2016-10-09 Thread Conrad Hoffmann
Hi, I have recently been looking at the POSIX Shell Command Language specification [1] and trying to understand how shells parse their input. One thing I am currently looking at is arithmetic expansion. I did some tests with Bash, and one thing seemed curious to me: In the Bash Reference Manual [