[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
$(( )): binary/unary VAR/NUM inconsistency
From: |
Steffen Nurpmeso |
Subject: |
$(( )): binary/unary VAR/NUM inconsistency |
Date: |
Wed, 06 Jul 2022 19:10:12 +0200 |
User-agent: |
s-nail v14.9.24-268-g937248580b |
Hello.
'Struggling with a Dijkstra two stack parser i am thankful to be
able to compare against bash that uses a completely different and
correct parser!
I stumbled upon this (bash 5.1.16); i find it "understandable" in
respect to clarity, but inconsistent, and also in hindsight to the
announcement of a forthcoming release i thought i report it quick:
$ bash -c 'I=10; echo $((1++I)); echo $I'
bash: line 1: 1++I: syntax error in expression (error token is "++I")
$ bash -c 'I=10; echo $((1++1)); echo $I'
10
$ bash -c 'I=10;echo "<$(( +10+++I ))>"'
<21>
$ bash -c 'I=10;echo "<$(( +10+ ++I ))>"'
<21>
$ bash -c 'I=10;echo "<$(( +10+ +I ))>"'
<20>
I would find it more consistent if nothing would be whitespace
affine.
(The parsers in the wild are exactly so, very much including mine
which leans upon the busybox shell parser, for example
$ busybox.static sh -c 'I=10;echo "<$(( +10+ +I ))>"'
<20>
$ busybox.static sh -c 'I=10;echo "<$(( +10++I ))>"'
<20>
$ busybox.static sh -c 'I=10;echo "<$(( +10+++I ))>"'
<21>
$ busybox.static sh -c 'I=10;echo "<$(( +10++ + + + + +I ))>"'
<20>
$ busybox.static sh -c 'I=10;echo "<$(( +10++ +++I ))>"'
sh: arithmetic syntax error
$ busybox.static sh -c 'I=10;echo "<$(( +10++ ++ +I ))>"'
sh: arithmetic syntax error
$ busybox.static sh -c 'I=10;echo "<$(( +10+ + ++ +I ))>"'
sh: arithmetic syntax error
$ busybox.static sh -c 'I=10;echo "<$(( +10 + + ++ +I ))>"'
sh: arithmetic syntax error
$ busybox.static sh -c 'I=10;echo "<$(( +10 + + ++ + +I ))>"'
sh: arithmetic syntax error
$ busybox.static sh -c 'I=10;echo "<$(( +10 + + + + + +I ))>"'
<20>
But am not ready here yet. Just for comparison.)
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)
- $(( )): binary/unary VAR/NUM inconsistency,
Steffen Nurpmeso <=
- Re: $(( )): binary/unary VAR/NUM inconsistency, Andreas Schwab, 2022/07/06
- Re: $(( )): binary/unary VAR/NUM inconsistency, Chet Ramey, 2022/07/07
- Re: $(( )): binary/unary VAR/NUM inconsistency, Steffen Nurpmeso, 2022/07/07
- Re: $(( )): binary/unary VAR/NUM inconsistency, Chet Ramey, 2022/07/08
- Re: $(( )): binary/unary VAR/NUM inconsistency, Steffen Nurpmeso, 2022/07/08
- Re: $(( )): binary/unary VAR/NUM inconsistency, Steffen Nurpmeso, 2022/07/08
- Re: $(( )): binary/unary VAR/NUM inconsistency, Chet Ramey, 2022/07/08
- Re: $(( )): binary/unary VAR/NUM inconsistency, Martin D Kealey, 2022/07/08
- Re: $(( )): binary/unary VAR/NUM inconsistency, Steffen Nurpmeso, 2022/07/09