diff --git a/base/download.jl b/base/download.jl index 1433fcbf27a03..ba9d8dd16d2a2 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" @@ -27,23 +27,25 @@ 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")