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")