bugmake - Bugs: bug #63667, In POSIX mode, the shell should...


bug #63667: In POSIX mode, the shell should not be run with -e if errors are ignored

Submitter:  Vincent Lefèvre <vinc17>
Submitted:  Sun 15 Jan 2023 01:47:08 AM UTC
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  None Operating System:  POSIX-Based
Fixed Release:  4.4.1 Triage Status:  Small Effort
* Mandatory Fields

Add a New Comment Rich Markup

Sat 28 Jan 2023 04:11:39 PM UTC, comment #1: 

This is actually a bit tricky.  GNU make allows the user to specify their own shell flags, so the real rule is "if the user didn't override the shell flags, AND POSIX is set, AND we're not ignoring errors, then use "-ec" as the shell flags.

I have implemented a fix, thanks for the report.

Paul D. Smith <psmith>
Group administrator
Sun 15 Jan 2023 01:47:08 AM UTC, original submission:  

As said at https://debbugs.gnu.org/cgi/bugreport.cgi?bug=55025#24 (about an issue with Automake) by Nick Bowler, when ".POSIX:" is used, GNU Make does not conform to POSIX when errors are ignored. This affects commands like

  @-false; echo hello

where "hello" is not output because the shell is run with -e (the following applies at least to GNU Make 4.3 and the Git current repository), which is incorrect. Indeed, job.c contains:

  if (shellflags == 0)
    shellflags = posix_pedantic ? "-ec" : "-c";

i.e. -e is always used in POSIX mode.

The POSIX standard[*] says:

"An execution line is built from the command line by removing any prefix characters. Except as described under the at-sign prefix, the execution line shall be written to the standard output, optionally preceded by a <tab>. The execution line shall then be executed by a shell as if it were passed as the argument to the system() interface, except that if errors are not being ignored then the shell -e option shall also be in effect. If errors are being ignored for the command (as a result of the -i option, a '-' command prefix, or a .IGNORE special target), the shell -e option shall not be in effect. The environment for the command being executed shall contain all of the variables in the environment of make."

[*] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html

If I understand correctly, errors are ignored if child->noerror or ignore_errors_flag is true. So, in this case, -e should not be used.

Vincent Lefèvre <vinc17>


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

Attach Files:

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 psmith (Posted a comment)
  • -email is unavailable- added by vinc17 (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.

    Only logged-in users can vote.


    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-01-28 psmith StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Operating SystemNone POSIX-Based
        Fixed ReleaseNone 4.4.1
        Triage StatusNone Small Effort

    Back to the top

    Powered by Savane 3.13-ee12.
    Corresponding source code