Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1b6f9e5

Browse files
authoredSep 6, 2022
fix: fix ERRPIPE in scripts/lib.sh (#3908)
1 parent 3264960 commit 1b6f9e5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
 

‎scripts/lib.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,11 @@ if [[ "${CODER_LIBSH_NO_CHECK_DEPENDENCIES:-}" != *t* ]]; then
152152
# old version of Make installed out of the box that doesn't support new
153153
# features like ONESHELL.
154154
#
155-
# Piping commands directly into `head -n1` may result in ERRPIPE errors, so
156-
# we capture the version output first before
157-
make_version_raw="$(make --version 2>/dev/null)"
158-
make_version="$(echo "$make_version_raw" | head -n1 | grep -oE '([[:digit:]]+\.){1,2}[[:digit:]]+')"
155+
# We have to disable pipefail temporarily to avoid ERRPIPE errors when
156+
# piping into `head -n1`.
157+
set +o pipefail
158+
make_version="$(make --version 2>/dev/null | head -n1 | grep -oE '([[:digit:]]+\.){1,2}[[:digit:]]+')"
159+
set -o pipefail
159160
if [[ ${make_version//.*/} -lt 4 ]]; then
160161
libsh_bad_dependencies=1
161162
log "ERROR: You need at least make 4.0 to run the scripts in the Coder repo."

0 commit comments

Comments
 (0)
Failed to load comments.