bug-make
[Top][All Lists]
Advanced

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

Re: [bug #40431] .SHELLFLAGS is passed to shell as single argument.


From: David Highley
Subject: Re: [bug #40431] .SHELLFLAGS is passed to shell as single argument.
Date: Thu, 31 Oct 2013 20:34:10 -0700 (PDT)

"Van de Bugger wrote:"
> 
> Follow-up Comment #2, bug #40431 (project make):
> 
> Thanks, I also found this trick independently. Unfortunately the trick does
> not work. Or, stricly speaking, it works, but there is an unwanted side effect
> which makes it useless. Look:
> 
> # Note: in current shell pipefail is not set.
> $ echo $SHELLOPTS
> braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
> # Starting a new shell with "-o pipefail".
> $ bash -o pipefail
> # In nested shell pipefail is set.
> $ echo $SHELLOPTS
> braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor:pipefail
> # Starting one more nested shell:
> $ bash
> # In gransson, pipefail is not set.
> $ echo $SHELLOPTS
> braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
> 
> It looks like shell options (real shell options specified in command line) are
> *not* inherited.
> 
> Now let us try to set SHELLOPTS variable:
> 
> # In current shell pipefailis not set:
> $ echo $SHELLOPTS
> braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
> # Starting a nested shell with modified SHELLOPTS:
> $ env SHELLOPTS=$SHELLOPTS:pipefail bash
> # Here pipefail is set, as expected:
> $ echo $SHELLOPTS
> braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor:pipefail
> # Starting one more nested shell:
> $ bash
> # And check pipefail: it is still set!
> $ echo $SHELLOPTS
> braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor:pipefail
> 
> Effect of SHELLOPTS *is* inherited. Practically it means that many third-party
> shell scripts invoked from make directly or indirectly will not work, because
> they do not expect pipefail (or erexit).
> 
> In my real makefile there is a command:
> 
> rpmbuild -bb foo.spec
> 
> With 
> 
> SHELLOPTS += pipefail:errexit
> 
> rpmbuild fails with no meanigful message. It reports something like this:
> "%install return non-zero status". I spend sometime to debug an issue and
> found that problem is in /usr/lib/rpm/check-buildroot script (it is an
> internal part of rpmbuild). It executes:
> 
> find ... | grep ... > $tmp
> 
> Grep finds nothing, returns status 1, and bash exits the script prematurely.
> 
> Thus, setting SHELLOPTS is not an option. :-(

A generic independent way of dealing with the shell exit status is:
# This sets the shell environment variable which will return an error
# # code if any subprocess exits with a failure code. The build process
# # will then stop if there are any errors.
SET_E                   = case '$(MFLAGS)' in *[ik]*) set +e;; *) set -e;; esac
$(OBJDIR)/%.$(OBJ_EXT): %.cpp
        $(SET_E); $(MKDIR) $(OBJDIR); $(COMPILE)

This allows for the make options -i or -k to turn off the stop on error
so that as many errors as possible can be found in one build.

> 
>     _______________________________________________________
> 
> Reply to this item at:
> 
>   <http://savannah.gnu.org/bugs/?40431>
> 
> _______________________________________________
>   Message sent via/by Savannah
>   http://savannah.gnu.org/
> 
> 
> _______________________________________________
> Bug-make mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/bug-make
> 



reply via email to

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