Skip to content

Commit 3f2478a

Browse files
committed
post-release: fix segfault in script when no replace is found
This change fixes #1024 Signed-off-by: Ridwan Sharif <[email protected]>
1 parent 19c4db6 commit 3f2478a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

verify_examples.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ for dir in $PACKAGE_DIRS; do
4747
printf " Update go.mod for $dir\n"
4848
(cd "${DIR_TMP}/${dir}" && \
4949
# replaces is ("mod1" "mod2" …)
50-
replaces=($(go mod edit -json | ${TOOLS_DIR}/gojq '.Replace[].Old.Path')) && \
50+
if [[ $(go mod edit -json | ${TOOLS_DIR}/gojq '.Replace') == "null" ]]; then
51+
echo "The 'Replace' field is null (no replace directives) for ${dir}."
52+
replaces=() # Initialize as an empty array
53+
else
54+
replaces=($(go mod edit -json | ${TOOLS_DIR}/gojq '.Replace[].Old.Path'))
55+
fi
5156
# strip double quotes
5257
replaces=("${replaces[@]%\"}") && \
5358
replaces=("${replaces[@]#\"}") && \

0 commit comments

Comments
 (0)