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 say

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 rel

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 nativ

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 cl

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, but

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 giv

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

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 ass

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

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

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, j;

Re: Read Prompt Width Miscalculation (Non-Printing Characters)

2022-12-29 Thread Chet Ramey
On 12/29/22 5:37 AM, The Administrator wrote: ... or you can write your prompt string as you would write PS1 and use the ${word@P} expansion when you pass it as an argument to `read' (preferred). This is new to me.  Thank you. Should I write a patch for the man page? The parameter transform

Re: Read Prompt Width Miscalculation (Non-Printing Characters)

2022-12-29 Thread The Administrator
... or you can write your prompt string as you would write PS1 and use the ${word@P} expansion when you pass it as an argument to `read' (preferred). This is new to me. Thank you. Should I write a patch for the man page?