Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions gap/PackageManager.gi
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,13 @@ function(name, interactive...)

# Look for VC repos
dirs := List(info, i -> ShallowCopy(i.InstallationPath));
for vc in [rec(cmd := "git", stflags := "-s", pullflags := "--ff-only"),
rec(cmd := "hg", stflags := "", pullflags := "-uy")] do
for vc in [rec(cmd := "git", stflags := ["-s"], pullflags := "--ff-only"),
rec(cmd := "hg", stflags := [], pullflags := "-uy")] do
repo := Filename(List(dirs, Directory), Concatenation(".", vc.cmd));
if repo <> fail then
dir := repo{[1 .. Length(repo) - Length("/.") - Length(vc.cmd)]};
status := PKGMAN_Exec(dir, vc.cmd, "status", vc.stflags);
status := CallFuncList(PKGMAN_Exec,
Concatenation([dir, vc.cmd, "status"], vc.stflags));
if status = fail then
return false;
elif status.code = 0 and status.output = "" then
Expand Down Expand Up @@ -292,13 +293,14 @@ function(dir, cmd, args...)
out := "";
outstream := OutputTextString(out, true);

# Execute the command (capture both stdout and stderr)
sh := PKGMAN_PathSystemProgram("sh");
args := JoinStringsWithSeparator(args, " ");
fullcmd := Concatenation(fullcmd, " ", args, " 2>&1");
# Execute the command (capture both stdout and stderr). The shell only adds
# the redirection; it gets command and arguments as positional parameters,
# so it never parses them.
# avoids temporary dir problems in stable-4.12
ChangeDirectoryCurrent(".");
code := Process(dir, sh, instream, outstream, ["-c", fullcmd]);
code := Process(dir, sh, instream, outstream,
Concatenation(["-c", "exec \"$0\" \"$@\" 2>&1", fullcmd],
args));
CloseStream(outstream);

if code <> 0 then
Expand Down
7 changes: 4 additions & 3 deletions gap/archive.gi
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ function(path)
# Check which version of tar we are using
tar := PKGMAN_Exec(".", "tar", "--version");
if StartsWith(tar.output, "tar (GNU tar)") then
options := "--warning=none";
options := ["--warning=none"];
else
options := "";
options := [];
fi;

# Check contents
exec := PKGMAN_Exec(".", "tar", options, "-tf", path);
exec := CallFuncList(PKGMAN_Exec,
Concatenation([".", "tar"], options, ["-tf", path]));
if exec.code <> 0 then
Info(InfoPackageManager, 1, "Could not inspect tarball contents");
return fail;
Expand Down
4 changes: 4 additions & 0 deletions tst/PackageManager.tst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ Error, <cmd> should be a string
gap> PKGMAN_Exec(".", "xyzabc");
fail

# PKGMAN_Exec passes arguments through verbatim, without a shell seeing them
gap> PKGMAN_Exec(".", "printf", "[%s]", "a b", "$(echo injected)", "").output;
"[a b][$(echo injected)][]"

# FINAL TEST
# (keep this at the end of the file)
gap> PKGMAN_SetCustomPackageDir(Filename(DirectoryTemporary(), "pkg/"));
Loading