Skip to content

Commit

Permalink
add PKGMAN_PathSystemProgram
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasBreuer committed Jun 20, 2024
1 parent 79002e6 commit 56bab1d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions gap/PackageManager.gi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@

BindGlobal("PKGMAN_WHITESPACE", MakeImmutable(" \n\t\r"));

BindGlobal("PKGMAN_PathSystemProgram", function(name)
local dir, path;

for dir in DirectoriesSystemPrograms() do
path:= Filename(dir, name);
if IsExecutableFile(path) then
return path;
fi;
od;
return fail;
end);

InstallGlobalFunction(GetPackageURLs,
function()
local get, urls, line, items;
Expand Down Expand Up @@ -1000,7 +1012,7 @@ function(dir, cmd, args...)
local sh, fullcmd, instream, out, outstream, code;

# Check shell
sh := Filename(DirectoriesSystemPrograms(), "sh");
sh := PKGMAN_PathSystemProgram("sh");
if sh = fail then
Info(InfoPackageManager, 1, "No shell available called \"sh\"");
return fail;
Expand All @@ -1020,7 +1032,7 @@ function(dir, cmd, args...)
fullcmd := cmd;
else
# we must look up the path
fullcmd := Filename(DirectoriesSystemPrograms(), cmd);
fullcmd := PKGMAN_PathSystemProgram(cmd);
if fullcmd = fail or not IsExecutableFile(fullcmd) then
Info(InfoPackageManager, 4, "Command ", cmd, " not found");
return fail;
Expand All @@ -1033,7 +1045,7 @@ function(dir, cmd, args...)
outstream := OutputTextString(out, true);

# Execute the command (capture both stdout and stderr)
sh := Filename(DirectoriesSystemPrograms(), "sh");
sh := PKGMAN_PathSystemProgram("sh");
args := JoinStringsWithSeparator(args, " ");
fullcmd := Concatenation(fullcmd, " ", args, " 2>&1");
code := Process(dir, sh, instream, outstream, ["-c", fullcmd]);
Expand Down

0 comments on commit 56bab1d

Please sign in to comment.