summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-01-04 02:42:58 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-01-04 02:42:58 +0900
commit0a6cb62169ebe1abb63aa5c70868df7c40441b1c (patch)
treef073430abe715b570bbd777b6a8dd1dde2e32af3 /install
parent9930a1d4d9cf92fe869f9352177dd24bdf1ac13f (diff)
Fall back to Ruby version when download failed
Diffstat (limited to 'install')
-rwxr-xr-xinstall50
1 files changed, 36 insertions, 14 deletions
diff --git a/install b/install
index 5a999301..46f65537 100755
--- a/install
+++ b/install
@@ -6,27 +6,49 @@ fzf_base=`pwd`
ARCHI=$(uname -sm)
download() {
- mkdir -p "$fzf_base"/bin
- cd "$fzf_base"/bin
echo "Downloading fzf executable ($1) ..."
- if curl -fL \
- https://github.com/junegunn/fzf-bin/releases/download/snapshot/${1}.tar.gz |
- tar -xz; then
- mv $1 fzf
- chmod +x fzf
+ mkdir -p "$fzf_base"/bin && cd "$fzf_base"/bin
+ if [ $? -ne 0 ]; then
+ echo "- Failed to create bin directory."
+ return 1
+ fi
+
+ local url=https://github.com/junegunn/fzf-bin/releases/download/snapshot/${1}.tar.gz
+ if which curl > /dev/null; then
+ curl -fL $url | tar -xz
+ elif which wget > /dev/null; then
+ wget -O - $url | tar -xz
else
- echo "Failed to download $1"
- exit 1
+ echo "- curl or wget required to download fzf executable."
+ return 1
+ fi
+
+ if [ ! -f $1 ]; then
+ echo "- Failed to download ${1}."
+ return 1
fi
- cd - > /dev/null
+
+ mv $1 fzf && chmod +x fzf && cd - > /dev/null && echo
}
+# Try to download binary executable
+binary_available=0
+downloaded=0
if [ "$ARCHI" = "Darwin x86_64" ]; then
- download fzf_darwin_amd64
+ binary_available=1
+ download fzf_darwin_amd64 && downloaded=1
elif [ "$ARCHI" = "Linux x86_64" ]; then
- download fzf_linux_amd64
-else # No prebuilt executable
- echo "No prebuilt binary for $ARCHI ... Installing legacy Ruby version ..."
+ binary_available=1
+ download fzf_linux_amd64 && downloaded=1
+fi
+
+if [ $downloaded -ne 1 ]; then
+ if [ $binary_available -eq 0 ]; then
+ echo -n "No prebuilt binary for $ARCHI ... "
+ else
+ echo -n "Failed to download binary executable ... "
+ fi
+ echo "Installing legacy Ruby version ..."
# ruby executable
echo -n "Checking Ruby executable ... "