From 34965edcdaf9ab363dc0ab3e6f5252328a19178a Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 4 Jul 2016 01:40:24 +0900 Subject: [PATCH] [install] Fall back to wget if curl failed Close #605 --- install | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/install b/install index b5ccb25..ef0008a 100755 --- a/install +++ b/install @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -u +set -o pipefail [[ "$@" =~ --pre ]] && version=0.13.2 pre=1 || version=0.13.2 pre=0 @@ -109,6 +110,14 @@ link_fzf_in_path() { 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() { echo "Downloading bin/fzf ..." if [ $pre = 0 ]; then @@ -128,12 +137,8 @@ download() { fi local url=https://github.com/junegunn/fzf-bin/releases/download/$version/${1}.tgz - if command -v curl > /dev/null; then - curl -fL $url | tar -xz - elif command -v wget > /dev/null; then - wget -O - $url | tar -xz - else - binary_error="curl or wget not found" + if ! (try_curl $url || try_wget $url); then + binary_error="Failed to download with curl and wget" return fi