bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Intriguing error with arithmetic evaluation


From: L. A. Walsh
Subject: Re: Intriguing error with arithmetic evaluation
Date: Sun, 21 Aug 2016 19:55:27 -0700
User-agent: Thunderbird



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.1.
---
        I don't recall (()) being in historical shells.  It appeared
to me that (()) was later added as a more general replacement of [].
After (()) was added came a change to trigger the errexit handler
after an arithmetic (()) expression producing an exit value.



You can't simultaneously complain that Posix didn't standardize existing
behavior and that Posix corrected a problem by which Posix deviated from
existing behavior.  Or maybe you can, I don't know.
---
   Bash didn't trigger "-e" errexit handling on (()).  POSIX
said (()) had to trigger such handling.  Saying it had to trigger such
handling was a deviation from how bash had worked.  I don't see
how that is not forcing a change in how bash handled (()), vs.
not forcing a change (using bash's existing behavior, in POSIX mode).




   Wrong -- the older scripts assume it worked only on simple
commands. POSIX changed that.

This is pretty much exactly the opposite of what happened.
---
   In the time I've used shell, I don't remember any /bin/sh (Bourne)
compatible shells that supported (()), so I can't see how adding
it to the list of covered commands would be anything but incompatible.
Posix
erred in specifying that set -e worked with simple commands.
---
   What non-simple commands from 92 or before did -e work on in
/bin/sh or /bin/bash, or even the original /bin/ksh.  Sun pulled in
various BSDisms into their SYSV shell after they converted from BSD
to SysVto support their customers, but that's because they had been
using BSDisms, when other vendors had been using SysV.

 and
existing scripts that relied on that historical behavior broke when
bash implemented that standard.
---
   When did bash change to only calling errexit on simple commands and
what had it done before that?


   More importantly, why did the non-posix mode have to change to follow
the new standard.

   The idea that posix made a mistake in the 1992 spec, is a
*questionable*.   If you use that rationale, ALL of posix could be
labeled "mistake", with a new posix release requiring win32 semantics. That wouldn't mean it was "portable" to older systems.

  Shells I used at Sun under (mostly) SysV, and at SGI followed the SysV
conventions, where I do not recall seeing (()) or errexit being applied
to non-simple commands.  Not that it's greatly useful, but one could
return short short unsigned or short short ints from functions and not
worry about an errexit invocation.  Wasn't that also changed?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]