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.
>
> bash works differently.
>
> From what I understand from past discussions on the subject here
> bash doesn't treat it as a syntax error and tries instead to tokenise
> those incorrect ++/-- into multiple + or - operators if possible.
This is more or less correct. Bash doesn't treat a token as a post-
increment or post-decrement unless the previous token is a string. Since
the previous token is a number (based on the evaluation of the pre-
increment), these are treated as a sequence of unary pluses.
In this case, we can add some additional error checking.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU [email protected] http://cnswww.cns.cwru.edu/~chet/