Skip to content

Commit

Permalink
bypass aliased curl
Browse files Browse the repository at this point in the history
add nvm_curl to control how curl is executed
  • Loading branch information
ryenus committed Nov 2, 2022
1 parent e6fa80c commit 881a01d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ nvm_node_version() {

nvm_download() {
if nvm_has "curl"; then
curl --fail --compressed -q "$@"
command curl --fail --compressed -q "$@"
elif nvm_has "wget"; then
# Emulate curl with wget
ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
Expand Down
14 changes: 9 additions & 5 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ nvm_has_colors() {
[ "${NVM_NUM_COLORS:--1}" -ge 8 ]
}

nvm_curl() {
command curl -q "$@"
}

nvm_curl_libz_support() {
curl -V 2>/dev/null | nvm_grep "^Features:" | nvm_grep -q "libz"
nvm_curl -V 2>/dev/null | nvm_grep "^Features:" | nvm_grep -q "libz"
}

nvm_curl_use_compression() {
Expand All @@ -101,7 +105,7 @@ nvm_get_latest() {
if nvm_curl_use_compression; then
CURL_COMPRESSED_FLAG="--compressed"
fi
NVM_LATEST_URL="$(curl ${CURL_COMPRESSED_FLAG:-} -q -w "%{url_effective}\\n" -L -s -S https://latest.nvm.sh -o /dev/null)"
NVM_LATEST_URL="$(nvm_curl ${CURL_COMPRESSED_FLAG:-} -q -w "%{url_effective}\\n" -L -s -S https://latest.nvm.sh -o /dev/null)"
elif nvm_has "wget"; then
NVM_LATEST_URL="$(wget -q https://latest.nvm.sh --server-response -O /dev/null 2>&1 | command awk '/^ Location: /{DEST=$2} END{ print DEST }')"
else
Expand All @@ -121,7 +125,7 @@ nvm_download() {
if nvm_curl_use_compression; then
CURL_COMPRESSED_FLAG="--compressed"
fi
curl --fail ${CURL_COMPRESSED_FLAG:-} -q "$@"
nvm_curl --fail ${CURL_COMPRESSED_FLAG:-} -q "$@"
elif nvm_has "wget"; then
# Emulate curl with wget
ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
Expand Down Expand Up @@ -465,7 +469,7 @@ nvm_clang_version() {
}

nvm_curl_version() {
curl -V | command awk '{ if ($1 == "curl") print $2 }' | command sed 's/-.*$//g'
nvm_curl -V | command awk '{ if ($1 == "curl") print $2 }' | command sed 's/-.*$//g'
}

nvm_version_greater() {
Expand Down Expand Up @@ -3004,7 +3008,7 @@ nvm() {
nvm_err "awk: not found"
fi
if nvm_has "curl"; then
nvm_err "curl: $(nvm_command_info curl), $(command curl -V | command head -n 1)"
nvm_err "curl: $(nvm_command_info curl), $(nvm_curl -V | command head -n 1)"
else
nvm_err "curl: not found"
fi
Expand Down

0 comments on commit 881a01d

Please sign in to comment.