Skip to content

Commit 46016b2

Browse files
authored
Handle curl 8.14.0 zero-exit bug (#617)
* Fix curl returning with a non-zero edit code on failure * Simplify expression
1 parent 16493e4 commit 46016b2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/dotnet-install.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,13 +1198,19 @@ downloadcurl() {
11981198
local curl_options="--retry 20 --retry-delay 2 --connect-timeout 15 -sSL -f --create-dirs "
11991199
local curl_exit_code=0;
12001200
if [ -z "$out_path" ]; then
1201-
curl $curl_options "$remote_path_with_credential" 2>&1
1201+
curl_output=$(curl $curl_options "$remote_path_with_credential" 2>&1)
12021202
curl_exit_code=$?
1203+
echo "$curl_output"
12031204
else
1204-
curl $curl_options -o "$out_path" "$remote_path_with_credential" 2>&1
1205+
curl_output=$(curl $curl_options -o "$out_path" "$remote_path_with_credential" 2>&1)
12051206
curl_exit_code=$?
12061207
fi
1207-
1208+
1209+
# Regression in curl causes curl with --retry to return a 0 exit code even when it fails to download a file - https://github.com/curl/curl/issues/17554
1210+
if [ $curl_exit_code -eq 0 ] && echo "$curl_output" | grep -q "^curl: ([0-9]*) "; then
1211+
curl_exit_code=$(echo "$curl_output" | sed 's/curl: (\([0-9]*\)).*/\1/')
1212+
fi
1213+
12081214
if [ $curl_exit_code -gt 0 ]; then
12091215
download_error_msg="Unable to download $remote_path."
12101216
# Check for curl timeout codes

0 commit comments

Comments
 (0)