Skip to content

Commit fd794bf

Browse files
committed
Fix "if modules enabled" check in common.sh
The code `(go mod edit -json &>/dev/null)` fails if modules are not enabled because of `set -o errexit`. This commit fixes it so the script continues its execution.
1 parent cf950d8 commit fd794bf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

common.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ set -o nounset
1818
set -o pipefail
1919

2020
# check if modules are enabled
21-
(go mod edit -json &>/dev/null)
22-
MODULES_ENABLED=$?
21+
MODULES_ENABLED=""
22+
if go mod edit -json &>/dev/null ; then
23+
MODULES_ENABLED="1"
24+
fi
2325

2426
MOD_OPT=""
2527
MODULES_OPT=${MODULES_OPT:-""}
26-
if [[ -n "${MODULES_OPT}" && $MODULES_ENABLED ]]; then
28+
if [[ -n "${MODULES_OPT}" && -n "${MODULES_ENABLED}" ]]; then
2729
MOD_OPT="-mod=${MODULES_OPT}"
2830
fi
2931

0 commit comments

Comments
 (0)