Skip to content

Commit

Permalink
Don't use which curl, use Sys.which("curl")
Browse files Browse the repository at this point in the history
This fixes issues on systems that don't have `which` available
  • Loading branch information
staticfloat committed Mar 23, 2018
1 parent 1004407 commit 5b500a6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions base/download.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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")
Expand Down

0 comments on commit 5b500a6

Please sign in to comment.