[install] Fall back to wget if curl failed

Close #605
This commit is contained in:
Junegunn Choi 2016-07-04 01:40:24 +09:00
parent bd4377084d
commit 34965edcda
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

17
install
View File

@ -1,6 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -u set -u
set -o pipefail
[[ "$@" =~ --pre ]] && version=0.13.2 pre=1 || [[ "$@" =~ --pre ]] && version=0.13.2 pre=1 ||
version=0.13.2 pre=0 version=0.13.2 pre=0
@ -109,6 +110,14 @@ link_fzf_in_path() {
return 1 return 1
} }
try_curl() {
command -v curl > /dev/null && curl -fL $1 | tar -xz
}
try_wget() {
command -v wget > /dev/null && wget -O - $1 | tar -xz
}
download() { download() {
echo "Downloading bin/fzf ..." echo "Downloading bin/fzf ..."
if [ $pre = 0 ]; then if [ $pre = 0 ]; then
@ -128,12 +137,8 @@ download() {
fi fi
local url=https://github.com/junegunn/fzf-bin/releases/download/$version/${1}.tgz local url=https://github.com/junegunn/fzf-bin/releases/download/$version/${1}.tgz
if command -v curl > /dev/null; then if ! (try_curl $url || try_wget $url); then
curl -fL $url | tar -xz binary_error="Failed to download with curl and wget"
elif command -v wget > /dev/null; then
wget -O - $url | tar -xz
else
binary_error="curl or wget not found"
return return
fi fi