Skip to content

Commit 16a0122

Browse files
committed
Merge pull request rbenv#140 from jayferd/use-wget
use `wget` if it's available and curl isn't
2 parents afd0799 + 772e175 commit 16a0122

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

bin/ruby-build

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,20 @@ make_package() {
8989
popd >&4
9090
}
9191

92+
if type curl &>/dev/null; then
93+
fetch_url() { curl "$@" ;}
94+
elif type wget &>/dev/null; then
95+
fetch_url() { wget -O- "$@" ;}
96+
else
97+
fetch_url() { echo "curl or wget is required" >&2; exit 1 ;}
98+
fi
99+
92100
fetch_tarball() {
93101
local package_name="$1"
94102
local package_url="$2"
95103

96104
echo "Downloading ${package_url}..." >&2
97-
{ curl "$package_url" > "${package_name}.tar.gz"
105+
{ fetch_url "$package_url" > "${package_name}.tar.gz"
98106
tar xzvf "${package_name}.tar.gz"
99107
} >&4 2>&1
100108
}

0 commit comments

Comments
 (0)