Re: Intriguing error with arithmetic evaluation

2016-08-24 Thread Greg Wooledge
On Wed, Aug 24, 2016 at 03:01:09PM +0100, Stephane Chazelas wrote: > Possibly HP-UX changed it? Sounds more likely than > Solaris changing it the other way round. > > What version of ksh is it based on? $ strings /bin/ksh | grep Version | tail -2 @(#)Version 11/16/88 (That command came from htt

Re: Intriguing error with arithmetic evaluation

2016-08-24 Thread Stephane Chazelas
2016-08-23 12:26:37 -0400, Greg Wooledge: [...] > > ksh -c '((0)); echo X' > > > > outputs X > > You forgot the -e. Here's ksh88: > > $ ksh -e -c '((0)); echo X' > $ uname -a > HP-UX imadev B.10.20 A 9000/785 2008897791 two-user license [...] Oops. I did test with -e on Solaris though $ Vers

Re: Intriguing error with arithmetic evaluation

2016-08-23 Thread Greg Wooledge
On Tue, Aug 23, 2016 at 05:15:25PM +0100, Stephane Chazelas wrote: > POSIX doesn't specify ((...)) (explicitely leaves it > unspecified), so is out of POSIX scope anyway. > > It was introduced by ksh88. > > There and in ksh93 (but not pdksh nor zsh) > > ksh -c '((0)); echo X' > > outputs X You

Re: Intriguing error with arithmetic evaluation

2016-08-23 Thread Stephane Chazelas
2016-08-12 14:22:32 -0400, Chet Ramey: [...] > The relevant change was probably the change in the set of commands to which > `set -e' applies. The (( command (among others) was added to that list > in bash-4.1. The change was the result of Posix changing the semantics > of the errexit option and

Re: Intriguing error with arithmetic evaluation

2016-08-21 Thread L. A. Walsh
Chet Ramey wrote: Posix made an error in the 1992 version, in that the specification of set -e was subtly incompatible with historical... The relevant change was probably the change in the set of commands to which `set -e' applies. The (( command (among others) was added to that list in bash-4

Re: Intriguing error with arithmetic evaluation

2016-08-21 Thread Chet Ramey
On 8/21/16 8:30 PM, L. A. Walsh wrote: > >Keeping "-e" semantics in a "bo[e]rn[e]-again-shell" > compatible with the original shell would be the smart way to > go. POSIX changed it to be incompatible with historical > implementations -- thus, creating a new standard (@Chet), that > was no long

Re: Intriguing error with arithmetic evaluation

2016-08-21 Thread L. A. Walsh
Greg Wooledge wrote: On Mon, Aug 15, 2016 at 03:15:13AM -0700, L. A. Walsh wrote: Calculations shouldn't ever trigger "-e" except for things like division by 0 (which doesn't trigger it, as the calculation dies before an return value can be calculated); it's counter-intuitive. You ma

Re: Intriguing error with arithmetic evaluation

2016-08-16 Thread Chet Ramey
On 8/16/16 12:16 PM, L. A. Walsh wrote: The relevant change was probably the change in the set of commands to which `set -e' applies. The change was the result of Posix changing the semantics of the errexit option and expanding its scope from simple commands to all commands. >

Re: Intriguing error with arithmetic evaluation

2016-08-16 Thread Greg Wooledge
On Tue, Aug 16, 2016 at 09:16:50AM -0700, L. A. Walsh wrote: > Perhaps you can explain why bash's "normal mode" had to change? I don't have a "why", but I do note this on http://mywiki.wooledge.org/BashFAQ/105/Answers See the answer for "Exercise 2". I repeat, because it needs to be repeated ev

Re: Intriguing error with arithmetic evaluation

2016-08-16 Thread L. A. Walsh
Chet Ramey wrote: On 8/15/16 6:15 AM, L. A. Walsh wrote: Chet Ramey wrote: The relevant change was probably the change in the set of commands to which `set -e' applies. The change was the result of Posix changing the semantics of the errexit option and expanding its scope from simp

Re: Intriguing error with arithmetic evaluation

2016-08-16 Thread Chet Ramey
On 8/15/16 6:15 AM, L. A. Walsh wrote: > > > Chet Ramey wrote: >> The relevant change was probably the change in the set of commands to which >> `set -e' applies. The (( command (among others) was added to that list >> in bash-4.1. The change was the result of Posix changing the semantics >> of

Re: Intriguing error with arithmetic evaluation

2016-08-15 Thread Greg Wooledge
On Mon, Aug 15, 2016 at 03:15:13AM -0700, L. A. Walsh wrote: > Calculations shouldn't ever trigger "-e" except for things like > division by 0 (which doesn't trigger it, as the calculation dies > before an return value can be calculated); it's counter-intuitive. You may wish as hard as you like, b

Re: Intriguing error with arithmetic evaluation

2016-08-15 Thread L. A. Walsh
Chet Ramey wrote: The relevant change was probably the change in the set of commands to which `set -e' applies. The (( command (among others) was added to that list in bash-4.1. The change was the result of Posix changing the semantics of the errexit option and expanding its scope from simpl

Re: Intriguing error with arithmetic evaluation

2016-08-12 Thread Chet Ramey
On 8/12/16 4:52 AM, NO REPLY wrote: > Bash Version: 4.3 > Patch Level: 11 > Release Status: release > > Description: > I have a few increment expressions used as ((level++)) and only one of > those is giving an error. When used with set -e, bash aborts > execution. Using ERR trap, I

Re: Intriguing error with arithmetic evaluation

2016-08-12 Thread Greg Wooledge
On Fri, Aug 12, 2016 at 02:22:26PM +0530, NO REPLY wrote: > I have a few increment expressions used as ((level++)) and only one of > those is giving an error. When used with set -e, bash aborts > execution. Using ERR trap, I was able to identify the expression. http://mywiki.wooledge.