Re: Arithmetic expression: evaluation order bug

2023-01-05 Thread Steffen Nurpmeso
Chet Ramey wrote in <30328892-c16b-5007-fee8-4b29430b7...@case.edu>: |On 1/4/23 12:21 PM, Steffen Nurpmeso wrote: |> Chet Ramey wrote in |> <8a61e01d-65c0-6c91-3575-399022fcb...@case.edu>: |>|On 12/30/22 3:44 PM, Steffen Nurpmeso wrote: |>| |>|> Digital, logical, liberal, yuck :) |>|

Re: Arithmetic expression: evaluation order bug

2023-01-04 Thread Chet Ramey
On 1/4/23 12:21 PM, Steffen Nurpmeso wrote: Chet Ramey wrote in <8a61e01d-65c0-6c91-3575-399022fcb...@case.edu>: |On 12/30/22 3:44 PM, Steffen Nurpmeso wrote: | |> Digital, logical, liberal, yuck :) | |We channeling Supertramp here? For a nice Breakfast in America, yes. (Not really

Re: Arithmetic expression: evaluation order bug

2023-01-04 Thread Steffen Nurpmeso
Chet Ramey wrote in <8a61e01d-65c0-6c91-3575-399022fcb...@case.edu>: |On 12/30/22 3:44 PM, Steffen Nurpmeso wrote: | |> Digital, logical, liberal, yuck :) | |We channeling Supertramp here? For a nice Breakfast in America, yes. (Not really that. But really.) Ciao, --steffen | |Der

Re: Arithmetic expression: evaluation order bug

2023-01-04 Thread Chet Ramey
On 1/4/23 10:36 AM, G. Branden Robinson wrote: ..and some spend their years watching the moon bear wank himself off. Or, if you were in Yorkshire last week, a walrus. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet

Re: Arithmetic expression: evaluation order bug

2023-01-04 Thread G. Branden Robinson
At 2023-01-04T10:22:15-0500, Chet Ramey wrote: > On 12/30/22 3:44 PM, Steffen Nurpmeso wrote: > > > Digital, logical, liberal, yuck :) > > We channeling Supertramp here? 藍 Some listen to the birds in the trees singing so happily... ..and some spend their years watching the moon bear wank

Re: Arithmetic expression: evaluation order bug

2023-01-04 Thread Chet Ramey
On 12/30/22 4:23 AM, Robert Elz wrote: For what it is worth, I tested a bunch of shells with the original expressions, all ksh variants, bosh, and bash evaluate the original expressions the bash way, all ash variants, plus yash and zsh implement it the dash way. Neither is incorrect. It

Re: Arithmetic expression: evaluation order bug

2023-01-04 Thread Chet Ramey
On 12/30/22 3:44 PM, Steffen Nurpmeso wrote: Digital, logical, liberal, yuck :) We channeling Supertramp here? -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.edu

Re: Arithmetic expression: evaluation order bug

2023-01-04 Thread Chet Ramey
On 12/29/22 12:23 PM, Steffen Nurpmeso wrote: Hello. Name: bash Path: /usr/ports/core Version: 5.2.15 Release: 1 > $ i=10 j=20;echo $(( i += j += i += j ));echo $i,$j 60 60,50 This has already been beaten pretty much to death, so I'll just

Re: Arithmetic expression: evaluation order bug

2022-12-30 Thread Robert Elz
Date:Fri, 30 Dec 2022 16:48:15 +0100 From:Steffen Nurpmeso Message-ID: <20221230154815.7-tqs%stef...@sdaoden.eu> | Of course i continue to disagree as i continue to | disagree on much of the sequence point outcome of ISO C, too. There's a big difference between

Re: Arithmetic expression: evaluation order bug

2022-12-30 Thread Steffen Nurpmeso
Robert Elz wrote in <10111.1672392...@jacaranda.noi.kre.to>: ... |The way to make this work is to insert sequence points, of which there |is only one which is plausible in shell arithmetic expressions, and even |that isn't required to exist by POSIX. | | $(( i += i, j += i, i += j )) |

Re: Arithmetic expression: evaluation order bug

2022-12-30 Thread Steffen Nurpmeso
Greg Wooledge wrote in : |On Fri, Dec 30, 2022 at 12:21:52AM +0100, Steffen Nurpmeso wrote: |> ..i want to reiterate the relation to what "human logic" expects. | |I'm a human, so I feel qualified to address this point. | |What I expect from a command like | |(( i += j += i += j )) |

Re: Arithmetic expression: evaluation order bug

2022-12-30 Thread Robert Elz
Date:Thu, 29 Dec 2022 21:57:00 + From:Alain D D Williams Message-ID: <20221229215700.gd16...@phcomp.co.uk> | So use sub-expressions to 'evaluate first' so you should prolly rewrite: | | (( i += j += i += i )) | | as: | | (( i += (j += (i += i)) ))

Re: Arithmetic expression: evaluation order bug

2022-12-29 Thread Alain D D Williams
On Fri, Dec 30, 2022 at 12:15:38AM +0100, Steffen Nurpmeso wrote: > Ah, wait.. > > Alain D D Williams wrote in > <20221229215700.gd16...@phcomp.co.uk>: > ... > |Anyway: back to what the shell should be doing. You cannot put a ';' \ > |into (( )) > |as a sequence point, but the manual does

Re: Arithmetic expression: evaluation order bug

2022-12-29 Thread Greg Wooledge
On Fri, Dec 30, 2022 at 12:21:52AM +0100, Steffen Nurpmeso wrote: > ..i want to reiterate the relation to what "human logic" expects. I'm a human, so I feel qualified to address this point. What I expect from a command like (( i += j += i += j )) is to get unpredictable results that have no

Re: Arithmetic expression: evaluation order bug

2022-12-29 Thread Steffen Nurpmeso
Andreas Schwab wrote in <87pmc194i6@igel.home>: |On Dez 30 2022, Steffen Nurpmeso wrote: ... |There is no right answer. But, do you know what? What you advocate contradicts thousands of years of human culture, religion and philosophie (to the best of my understanding), including your

Re: Arithmetic expression: evaluation order bug

2022-12-29 Thread Andreas Schwab
On Dez 30 2022, Steffen Nurpmeso wrote: > Not me!! Bash does it right for x=++x, There is no right answer. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."

Re: Arithmetic expression: evaluation order bug

2022-12-29 Thread Andreas Schwab
On Dez 30 2022, Steffen Nurpmeso wrote: > Andreas Schwab wrote in > <87358xambe@igel.home>: > |On Dez 29 2022, Alain D D Williams wrote: > |> On Thu, Dec 29, 2022 at 10:30:09PM +0100, Steffen Nurpmeso wrote: > |> > |>> only clang warns on sequencing when tested. > |> > |> Ah: so only

Re: Arithmetic expression: evaluation order bug

2022-12-29 Thread Steffen Nurpmeso
And, lastly (from my side).. Steffen Nurpmeso wrote in <20221229231538.pz4j9%stef...@sdaoden.eu>: ... |Alain D D Williams wrote in | <20221229215700.gd16...@phcomp.co.uk>: | ... ||Anyway: back to what the shell should be doing. You cannot put a ';' \ ||into (( )) ||as a sequence point,

Re: Arithmetic expression: evaluation order bug

2022-12-29 Thread Steffen Nurpmeso
Ah, wait.. Alain D D Williams wrote in <20221229215700.gd16...@phcomp.co.uk>: ... |Anyway: back to what the shell should be doing. You cannot put a ';' \ |into (( )) |as a sequence point, but the manual does say: | |"Sub-expressions in parentheses are evaluated first and may override the

Re: Arithmetic expression: evaluation order bug

2022-12-29 Thread Steffen Nurpmeso
Andreas Schwab wrote in <87358xambe@igel.home>: |On Dez 29 2022, Alain D D Williams wrote: |> On Thu, Dec 29, 2022 at 10:30:09PM +0100, Steffen Nurpmeso wrote: |> |>> only clang warns on sequencing when tested. |> |> Ah: so only clang gives the warning that the others should probably

Re: Arithmetic expression: evaluation order bug

2022-12-29 Thread Steffen Nurpmeso
Alain D D Williams wrote in <20221229215700.gd16...@phcomp.co.uk>: |On Thu, Dec 29, 2022 at 10:30:09PM +0100, Steffen Nurpmeso wrote: |> But then shell "operators and their precedence, associativity, |> and values are the same as in the C language". There are no |> sequence points. |

Re: Arithmetic expression: evaluation order bug

2022-12-29 Thread Andreas Schwab
On Dez 29 2022, Alain D D Williams wrote: > On Thu, Dec 29, 2022 at 10:30:09PM +0100, Steffen Nurpmeso wrote: > >> only clang warns on sequencing when tested. > > Ah: so only clang gives the warning that the others should probably give. $ gcc -Wall t.c t.c: In function ‘main’: t.c:7:11: warning:

Re: Arithmetic expression: evaluation order bug

2022-12-29 Thread Alain D D Williams
On Thu, Dec 29, 2022 at 10:30:09PM +0100, Steffen Nurpmeso wrote: > But then shell "operators and their precedence, associativity, > and values are the same as in the C language". There are no > sequence points. Order of evaluation is not the same as precedence/associativity. > += is right

Re: Arithmetic expression: evaluation order bug

2022-12-29 Thread Steffen Nurpmeso
Alain D D Williams wrote in <20221229204511.gc16...@phcomp.co.uk>: ... |No. i += j += i += i does not contain a sequence point so there is \ |no guarantee |that anything is completed (eg storing a value in variable i) before \ |another |part (getting a value from variable i) is evaluated.

Re: Arithmetic expression: evaluation order bug

2022-12-29 Thread Alain D D Williams
On Thu, Dec 29, 2022 at 09:09:25PM +0100, Emanuele Torre wrote: > On Thu, Dec 29, 2022 at 05:35:48PM +, Alain D D Williams wrote: > > On Thu, Dec 29, 2022 at 06:23:09PM +0100, Steffen Nurpmeso wrote: > > > Hello. > > > > > > Name: bash > > > Path: /usr/ports/core > > >

Re: Arithmetic expression: evaluation order bug

2022-12-29 Thread Emanuele Torre
On Thu, Dec 29, 2022 at 05:35:48PM +, Alain D D Williams wrote: > On Thu, Dec 29, 2022 at 06:23:09PM +0100, Steffen Nurpmeso wrote: > > Hello. > > > > Name: bash > > Path: /usr/ports/core > > Version: 5.2.15 > > Release: 1 > > > > $ i=10 j=20;echo $(( i +=

Re: Arithmetic expression: evaluation order bug

2022-12-29 Thread Steffen Nurpmeso
Alain D D Williams wrote in <20221229173548.gw16...@phcomp.co.uk>: |On Thu, Dec 29, 2022 at 06:23:09PM +0100, Steffen Nurpmeso wrote: |> Hello. |> |> Name: bash |> Path: /usr/ports/core |> Version: 5.2.15 |> Release: 1 |> |> $ i=10 j=20;echo $(( i +=

Re: Arithmetic expression: evaluation order bug

2022-12-29 Thread Alain D D Williams
On Thu, Dec 29, 2022 at 06:23:09PM +0100, Steffen Nurpmeso wrote: > Hello. > > Name: bash > Path: /usr/ports/core > Version: 5.2.15 > Release: 1 > > $ i=10 j=20;echo $(( i += j += i += j ));echo $i,$j > 60 > 60,50 > $ i=10 j=20;echo $(( i += j += i += i

Arithmetic expression: evaluation order bug

2022-12-29 Thread Steffen Nurpmeso
Hello. Name: bash Path: /usr/ports/core Version: 5.2.15 Release: 1 $ i=10 j=20;echo $(( i += j += i += j ));echo $i,$j 60 60,50 $ i=10 j=20;echo $(( i += j += i += i ));echo $i,$j 50 50,40 $ cat t.c #include int main(void){ int i,