Summary: | [Future EAPI] enable "set -e", "set -o pipefail", and "shopt -s failglob" in ebuilds | ||
---|---|---|---|
Product: | Gentoo Hosted Projects | Reporter: | Patrick McLean <chutzpah> |
Component: | PMS/EAPI | Assignee: | PMS/EAPI <pms> |
Status: | RESOLVED WONTFIX | ||
Severity: | normal | CC: | esigra, fturco, pacho, zmedico |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
See Also: |
https://bugs.gentoo.org/show_bug.cgi?id=566382 https://bugs.gentoo.org/show_bug.cgi?id=566384 |
||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Bug Depends on: | |||
Bug Blocks: | 174380 |
Description
Patrick McLean
2018-10-03 23:11:45 UTC
We have previously discussed pipefail, and the conclusion was that it would make legitimate code fail. Examples include "command | grep -q" and "xz -d | tar xf -". See bug 566382. "set -e" has been discussed too, in 2010: https://archives.gentoo.org/gentoo-dev/message/a92f5f7bdadfaa746507fc11c38baa67 The example in bug #566382 could also fail to catch failures that one intended to catch. If you actually expect the first command in a pipeline to fail, you can do something like: { ./configure --help 2>&1 || true; } | grep -q '^ *--docdir='; printf '%s\n' "${?}" That would make it clear that the first command is expected to fail while not failing the whole pipeline. Certainly "set -e" would make it so one has to check more carefully that the result of random commands is true, but adding "|| true" after a command that is expected might fail is probably a reasonable approach. You could also use the already existing "nonfatal" for these commands as well... Unfortunately, set -e has some really odd behaviors in bash. For example, try this: bash -c "( set -e; false; echo bad; ) || echo good" There are more examples here: http://mywiki.wooledge.org/BashFAQ/105 (In reply to Zac Medico from comment #4) WONTFIX then? Yes, sadly set -e appears to be essentially unusable. |