Re: $(()) pre/postfix bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02/07/2022 01:28, Robert Elz wrote:
   | FreeBSD 13.1
   | #|f-1301-x86:~$ sh -c '(i=10; echo $((++-+++i)))'
   | sh: arithmetic expression: expecting primary: "++-+++i"

We used to do that as well (our arith parser is derived from
theirs, which is derived from dash's with extensions) but no-one ever
understood what a "primary" was (relates to internal implementation
function names) so I altered the err msg.

While there is a function called primary, I actually think that may not be what the error message refers to, not directly. The grammar is supposed to be the C grammar with unsupported constructs removed, the C grammar defines a "primary-expression", and the error message in dash shows up where a straightforward parser directly based on the C grammar would result in an error where the grammar demands a primary-expression.

The function called primary ended up doing more than parse a primary-expression, but that does not change which cases result in that error.

Cheers,
Harald van Dijk



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux