From 5239a75baf2122413d52c03c7f5a5f73ab34ebfb Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Wed, 21 Mar 2018 10:29:38 -0700 Subject: [PATCH] Don't use `which curl`, use `Sys.which("curl")` This fixes issues on systems that don't have `which` available --- base/download.jl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/base/download.jl b/base/download.jl index f4d564d93f0f4..d1c82f975c72a 100644 --- a/base/download.jl +++ b/base/download.jl @@ -4,7 +4,7 @@ downloadcmd = nothing if Sys.iswindows() - downloadcmd = :powershell + downloadcmd = "powershell" function download(url::AbstractString, filename::AbstractString) ps = "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" tls12 = "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12" @@ -18,23 +18,24 @@ else function download(url::AbstractString, filename::AbstractString) global downloadcmd if downloadcmd === nothing - for checkcmd in (:curl, :wget, :fetch) - if success(pipeline(`which $checkcmd`, devnull)) + for checkcmd in ("curl", "wget", "fetch") + try + # Sys.which() will throw() if it can't find `checkcmd` + Sys.which(checkcmd) downloadcmd = checkcmd - break end end end - if downloadcmd == :wget + if downloadcmd == "wget" try run(`wget -O $filename $url`) catch rm(filename) # wget always creates a file rethrow() end - elseif downloadcmd == :curl + elseif downloadcmd == "curl" run(`curl -g -L -f -o $filename $url`) - elseif downloadcmd == :fetch + elseif downloadcmd == "fetch" run(`fetch -f $filename $url`) else error("no download agent available; install curl, wget, or fetch")