patchThe GNU Bourne-Again SHell - Patches: patch #7638, exit-code triggered error behavior...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #7638: exit-code triggered error behavior changed in 4.1: incompat w/earlier versions of POSIX

Submitter:  Linda A. Walsh <law>
Submitted:  Fri 21 Oct 2011 08:41:05 PM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Wont Do Privacy:  Public
Assigned to:  None Open/Closed:  Open

Sun 23 Oct 2011 08:50:10 PM UTC, comment #3: 

Here's a better definition of 'simple command'.
2.9.1 Simple Commands

A "simple command" is a sequence of optional variable assignments and redirections, in any sequence, optionally followed by words and redirections, terminated by a control operator.

When a given simple command is required to be executed (that is, when any conditional construct such as an AND-OR list or a case statement has not bypassed the simple command), the following expansions, assignments, and redirections shall all be performed from the beginning of the command text to the end:

   1.

      The words that are recognized as variable assignments or redirections according to Shell Grammar Rules are saved for processing in steps 3 and 4.
   2.

      The words that are not variable assignments or redirections shall be expanded. If any fields remain following their expansion, the first field shall be considered the command name and remaining fields are the arguments for the command.
   3.

      Redirections shall be performed as described in Redirection.
   4.

      Each variable assignment shall be expanded for tilde expansion, parameter expansion, command substitution, arithmetic expansion, and quote removal prior to assigning the value.

In the preceding list, the order of steps 3 and 4 may be reversed for the processing of special built-in utilities; see Special Built-In Utilities.

****
If no command name results, variable assignments shall affect the current execution environment.
****


 Otherwise, the variable assignments shall be exported for the execution environment of the command and shall not affect the current execution environment (except for special built-ins). If any of the variable assignments attempt to assign a value to a read-only variable, a variable assignment error shall occur. See Consequences of Shell Errors for the consequences of these errors.


The only case in which a variable assignment should result in an error or err-exit is assignment to a read-only variable.


Linda A. Walsh <law>
Sun 23 Oct 2011 08:45:53 PM UTC, comment #2: 

Actually, it's changed not from the earliest, but from the 2004 specification.

I refer you to this description for the "-e" option:
-e
    When this option is on, if a simple command fails for any of the reasons listed in Consequences of Shell Errors or returns an exit status value >0, and is not part of the compound list following a while, until, or if keyword, and is not a part of an AND or OR list, and is not a pipeline preceded by the ! reserved word, then the shell shall immediately exit.

From the above, one would determine that 'let' and '(())', NOT being simple commands, would not cause an exit (no matter what their return value is). 

The above can be found in the POSIX's reference materials, @
http://pubs.opengroup.org/onlinepubs/009695399/utilities/set.html


Any specifications that CHANGE the above would quite likely be, by definition, incompatible with the Posix standard from 2004 and before.

As the idea of posix is to provide for portability, having multiple versions of posix, is nearly as bad as having multiple flavors of unix.  They become the problem they were trying to solve by iterative refinement of the solution over time until transcription errors are introduced between generations.   Then the standard begins to diverge and become something else -- which would seem to be contrary to why it was created.



Linda A. Walsh <law>
Sun 23 Oct 2011 01:12:49 AM UTC, comment #1: 



Chet Ramey wrote:

> >> Details:
>>
>> The new version of bash in non-posix mode (this is likely changed in
>> POSIX mode as well, but in non-posix mode it didn't need to be,
>> pointlessly, made incompatible) has broken compatibility with the early
>> POSIX specs in following the newer 'portable OS *[non]*
>> interoperability Xchange' specification'.
>>
>> Previous versions of the posix compliant shell standard required an
>> error exit after a non-0 return status from a *simple* command.
>>
>> This was changed to include complex commands, which, by their nature,
>> are complex, and shouldn't be judged as 'failed', by a simple error
>> code. Some of those command are integer calculations that can evaluate
>> to 0 as often as not -- and NOT have it mean one should exit the
>> program.
>
> Really?




You really don't know the history of the Posix compatible shell?
No wonder you are letting multiple compat problems creep through at the
POSIX standard committee and in the newer versions of Bash.

;-/



Linda A. Walsh <law>
Fri 21 Oct 2011 08:41:05 PM UTC, original submission:  

The new version of bash in non-posix mode (this is likely changed in POSIX mode as well, but in non-posix mode it didn't need to be, pointlessly, made incompatible) has broken compatibility with the early POSIX specs in following the newer 'portable OS *[non]* interoperability Xchange' specification'.

I inserted 'non', is programs developed under it are not interoperable with programs and OS developed under the initial version.  I would cite this as a case of POSIX going so far as to violate itself, in improving itself, for no good reason.

Previous versions of the posix compliant shell standard required an error exit after a non-0 return status from a simple command.

This was changed to include complex commands, which, by their nature, are complex, and shouldn't be judged as 'failed', by a simple error code.   Some of those command are integer calculations that can evaluate to 0 as often as not -- and NOT have it mean one should exit the program.

In no way am suggesting the error codes returned be changed -- they were the same before as now.  It's only the behavior of when an exit is triggered while running with "-e".

If this is needed in POSIX mode to make it compatible with the new, incompatible POSIX standard, then make it a posix-only behavior.  The previous behavior was useful.  The current behavior is not.





Linda A. Walsh <law>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by chet (Updated the item)
  • -email is unavailable- added by law (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-05-04 chet StatusNone Wont Do

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code