Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/freebsd/poudriere.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Drewery <bryan@shatow.net>2019-02-28 04:13:13 +0300
committerBryan Drewery <bryan@shatow.net>2019-02-28 04:15:17 +0300
commitd883c4a451089b0fecab1efc37b8e61905943baf (patch)
tree29c07b2bbc4d7e5f794e7811a48218a7de06ddcb /src/share/poudriere/include
parente283e68741c0c72f0868f03f6b7251b34be05270 (diff)
Only enable pipefail if the shell supports it.
In non-interactive 'set -o pipefail' will immediately exit if the shell doesn't support pipefail. The method used here avoids a fork.
Diffstat (limited to 'src/share/poudriere/include')
-rw-r--r--src/share/poudriere/include/util.sh21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/share/poudriere/include/util.sh b/src/share/poudriere/include/util.sh
index 350a4b35..19371c71 100644
--- a/src/share/poudriere/include/util.sh
+++ b/src/share/poudriere/include/util.sh
@@ -704,13 +704,32 @@ nopipe() {
return ${_ret}
}
+# Detect if pipefail support is available in the shell. The shell
+# will just exit if we try 'set -o pipefail' and it doesn't support it.
+have_pipefail() {
+ local seto=$(set -o)
+
+ case ${seto} in
+ *pipefail*)
+ return 0
+ ;;
+ esac
+ return 1
+}
+
+set_pipefail() {
+ if have_pipefail; then
+ set -o pipefail
+ fi
+}
+
prefix_stderr_quick() {
local -; set +x
local extra="$1"
local MSG_NESTED_STDERR prefix
shift 1
- set -o pipefail
+ set_pipefail
{
{