From d3f0f6b280599ddc525ecaad8a10bca85b549bcf Mon Sep 17 00:00:00 2001 From: Dean Sheather Date: Tue, 6 Sep 2022 18:31:19 +0000 Subject: [PATCH] fix: fix ERRPIPE in scripts/lib.sh --- scripts/lib.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/lib.sh b/scripts/lib.sh index 0d6fb578d889c..02b8f234ede38 100644 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -152,10 +152,11 @@ if [[ "${CODER_LIBSH_NO_CHECK_DEPENDENCIES:-}" != *t* ]]; then # old version of Make installed out of the box that doesn't support new # features like ONESHELL. # - # Piping commands directly into `head -n1` may result in ERRPIPE errors, so - # we capture the version output first before - make_version_raw="$(make --version 2>/dev/null)" - make_version="$(echo "$make_version_raw" | head -n1 | grep -oE '([[:digit:]]+\.){1,2}[[:digit:]]+')" + # We have to disable pipefail temporarily to avoid ERRPIPE errors when + # piping into `head -n1`. + set +o pipefail + make_version="$(make --version 2>/dev/null | head -n1 | grep -oE '([[:digit:]]+\.){1,2}[[:digit:]]+')" + set -o pipefail if [[ ${make_version//.*/} -lt 4 ]]; then libsh_bad_dependencies=1 log "ERROR: You need at least make 4.0 to run the scripts in the Coder repo."