Skip to content

Commit b87b30a

Browse files
otaviofRoming22
authored andcommitted
fix: Capture Curl Return Code (SC2181)
1 parent baf0e13 commit b87b30a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

installer/scripts/test-url.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ probe_url() {
2929
--show-error \
3030
--fail \
3131
--location \
32+
--insecure \
33+
--max-time 30 \
3234
--output /dev/null \
3335
--write-out "%{http_code}" \
3436
"${URL}"
35-
)
36-
if [[ "${?}" -ne 0 ]]; then
37-
echo "# ERROR: Failed to fetch URL '${URL}'."
37+
) || curl_exit=${?}
38+
39+
if [[ "${curl_exit:-0}" -ne 0 ]]; then
40+
echo "# ERROR: Failed to fetch URL '${URL}', returned '${curl_exit}'." >&2
3841
return 1
3942
fi
4043

@@ -43,7 +46,7 @@ probe_url() {
4346
return 0
4447
else
4548
echo "# ERROR: '${URL}' returned status code '${response_code}'" \
46-
" expected ${STATUS_CODE}."
49+
" expected ${STATUS_CODE}." >&2
4750
return 1
4851
fi
4952
}
@@ -81,6 +84,6 @@ if test_url; then
8184
exit 0
8285
else
8386
echo "# ERROR: URL '${URL}' is not accessible or returned an" \
84-
"unexpected status code."
87+
"unexpected status code." >&2
8588
exit 1
8689
fi

0 commit comments

Comments
 (0)