Sigh.
I am deeply sorry, but i really have to come back.
Now, this is ridiculous. I am sorry for that.
...
|The three new tests
|
| s I1=I2=0 I2=5 I3=I2+=1;p "<$((I1?I1:I3))>";e "<$I1><$I2><$I3>"
| s I1=I1=10 I2=5 I3=I2+=1;p "<$((I1=0?I1:I3))>";e "<$I1><$I2><$I3>"
| s I1=I1=10 I2=5 I3=I2+=1;p "<$((I1=1?I1:I3))>";e "<$I1><$I2><$I3>"
...
|Interestingly we now have a divergence to the bash $(())
|implementation, and i have opened a bash bug report because of it,
Brain damage.
|as i think we are correct: given this file
|
| # make this work with (ba)sh \
| command -v shopt && shopt -s expand_aliases;\
| alias p=printf;alias e=echo;alias s=export
| s I1=I1=10 I2=5 I3=I2+=1;p "<$((I1=0?I1:I3))>";e "<$I1><$I2><$I3>"
| s I1=I1=10 I2=5 I3=I2+=1;p "<$((I1=1?I1:I3))>";e "<$I1><$I2><$I3>"
|
|we get
|
| -<6><6><6><I2+=1>
| -<10><10><5><I2+=1>
| +<6><0><6><I2+=1>
| +<1><1><5><I2+=1>
|
|compared to bash, and i think the latter two are correct.
No, they are not. Bash is likely correct there according to
standard precedence rules, as pointed out by Koichi Murase on
bug-bash@, the assignment needs to be lost completely due to
precedence rules, as they come in via ISO C:
$ cat t.c;tcc -run t.c
#include <stdio.h>
int main(void){
int i=5,j=10;
printf("%d\n", (i=100?i:j));
printf("%d\n",i);
return 0;
}
5
5
Hm,hm. I think this needs special treatment. Unchanged busybox
$(()) gets that wrong too, but a tad different.
People. I am sorry for all that. I really thought i paved my way
through the problems, _before_ i sent the first mail of this
thread. I will now implement this precedence fix and let the
thing rest for a while, maybe something else shows up to be fixed.
I really cannot imagine, but now i am confused as well, so better
it is to stand back and wait a while.
I will send a third version, and a furtherly extended test, once
that ship has sailed. Maybe then directly stripped down and
better integrated for busybox (smallified).
Thank you. And ciao.
--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)
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox