Skip to content

Commit

Permalink
Correct shell escaping in 7zip command
Browse files Browse the repository at this point in the history
Fixes #340
  • Loading branch information
ararslan committed Dec 8, 2017
1 parent dbba2bd commit 574bcac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/BinDeps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,13 @@ if Compat.Sys.iswindows()
const exe7z = joinpath(JULIA_HOME, "7z.exe")

function unpack_cmd(file,directory,extension,secondary_extension)
if ((extension == ".Z" || extension == ".gz" || extension == ".xz" || extension == ".bz2") &&
secondary_extension == ".tar") || extension == ".tgz" || extension == ".tbz"
return pipeline(`$exe7z x $file -y -so`, `$exe7z x -si -y -ttar -o$directory`)
elseif (extension == ".zip" || extension == ".7z" || extension == ".tar" ||
(extension == ".exe" && secondary_extension == ".7z"))
return (`$exe7z x $file -y -o$directory`)
if (extension in [".Z", ".gz", ".xz", ".bz2"] && secondary_extension == ".tar") ||
extension == ".tgz" || extension == ".tbz"
return pipeline(Cmd([exe7z, "x", file, "-y", "-so"]),
Cmd([exe7z, "x", "-si", "-y", "-ttar", "-o" * directory]))
elseif extension in [".zip", ".7z", ".tar"] ||
(extension == ".exe" && secondary_extension == ".7z")
return Cmd([exe7z, "x", file, "-y", "-o" * directory])
end
error("I don't know how to unpack $file")
end
Expand Down
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ let gv = glibc_version()
@test gv === nothing
end
end

if Compat.Sys.iswindows()
file = "C:\\junk.zip"
dir = "D:\\junk"
@test BinDeps.unpack_cmd(file, dir, ".zip", "") ==
`$(joinpath(JULIA_HOME, "7z.exe")) -x $file -y -o $dir`
end

0 comments on commit 574bcac

Please sign in to comment.