URL:
  <http://savannah.gnu.org/bugs/?40431>

                 Summary: .SHELLFLAGS is passed to shell as single argument.
                 Project: make
            Submitted by: van_de_bugger
            Submitted on: Wed 30 Oct 2013 09:15:32 PM GMT
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: 3.82
        Operating System: POSIX-Based
           Fixed Release: None
           Triage Status: None

    _______________________________________________________

Details:

I am trying to use .ONESHELL. I want shell to stop executing commands as soon
as a command returns non-zero status. Here is my test Makefile:

.ONESHELL :
all :
        false
        echo "OK"

Ok, the test:

$ make
false
echo "OK"
OK

Oops, false returns non-zero status, but shell continues, it's bad. "set -e"
as the first command of the recipe helps, but it is too boring and error-prone
to add a command to every recipe. Let us try .SHELLFLAGS -- it seems it is
what I need:

.SHELLFLAGS = -e -c

Oops:

$ make
false
echo "OK"
/bin/sh: - : invalid option
make: *** [all] Error 1

Error message is rather unclear. "-" is an invalid option? Ok, let us try
another variant:

.SHELLFLAGS = -ec

$ make
false
echo "OK"
make: *** [all] Error 1

Ok, good. But it seems make treats value of .SHELLFLAGS as single argument. It
may be suitable in simple cases, but it is not good in more complex
scenarios.

Now let us try solve another task: Stop execution if *any* command in pipe
fails. Here is modified Makefile:

.ONESHELL :
.SHELLFLAGS = -ec
all :
        false | true
        echo "OK"

By default, status of pipe is a status of the last command. Thus, "true" will
hide a problem occurred before, and execution will continue:

$ make
false | true
echo "OK"
OK

I want the process stopped. It could be done by bash command

set -o pipefail

(All the commands in pipe will be completed, but execution will not go
further.) Unfortunately, there is no short one-letter option to enable
pipefail which can be bundled with -ec. The only way to enable pipefail is "-o
pipefail", but

.SHELLFLAGS = -o pipefail -ec

does not work.

Resume: I think it would be helpful if make splits value of .SHELLFLAGS into
words and pass every word to shell as a separate argument.





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?40431>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/


_______________________________________________
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make

Reply via email to