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. :-(
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?40431>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
_______________________________________________
Bug-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-make