Support curl from a snap (#3329)

This commit is contained in:
native-api 2025-09-14 07:23:41 +03:00 committed by GitHub
parent 2ecd676a2a
commit 17fb66cd8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -458,7 +458,14 @@ http_head_curl() {
}
http_get_curl() {
curl -q -o "${2:--}" -sSLf ${CURL_OPTS} "$1"
local out;
# Curl is also available as a snap. Snaps cannot read or write /tmp
# (files cannot be found, any write result is silently discarded).
local curl_is_snap;
if [[ $(command -v curl) == "/snap/"* ]]; then curl_is_snap=1; fi
if [[ -n $2 && -n $curl_is_snap ]]; then out="$HOME/$(basename "$2")"; else out="$2"; fi
curl -q -o "${out:--}" -sSLf ${CURL_OPTS} "$1" || return $?
if [[ -n $out && -n $curl_is_snap ]]; then mv "$out" "$2"; fi
}
http_head_wget() {