Re: $(()) pre/postfix bug

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

 



    Date:        Sat, 02 Jul 2022 01:14:39 +0200
    From:        Steffen Nurpmeso <steffen@xxxxxxxxxx>
    Message-ID:  <20220701231439.egWzS%steffen@xxxxxxxxxx>

  | While doing so i encountered diverging behaviour in between
  | shells, and a bur in dash

Support for ++/-- in sh arith is not required, it l9oks as
if dash does not support them.  Without ++ support ++i is
just + + i

  | (and a memory failure in NetBSD 9 ksh).

that thing is full of bugs.

  | For my own thing i hope i end up like bash (that is: just do it
  | (tm)),

If anything, tgat one is br9ken, tokens are supposed to always
be interpreted left to right, longest possible token matches
(not the one that allows the rest of the expression to parse).

But as ++ support is optional, the rules for it are a bit up
in the air ... but $(( )) is supposed to evwluate just like 
Ç with the various caveats about what is not required.

  | #?0|kent:$ bash -c '(i=10; echo $((++-+++i)))'
  | -11

So that should be equiv to ++ - ++ + i [assuming support for ++]
in which there are two ++ operators not followed (or following)
a var name (aka lvalue).  Error.

  | 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.

kre



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

  Powered by Linux