Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Merged
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
14 changes: 11 additions & 3 deletions src/GitHub.Api/OutputProcessors/ProcessManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,32 @@ public void RunCommandLineWindow(NPath workingDirectory)
if (environment.IsWindows)
{
startInfo.FileName = "cmd";
gitEnvironment.Configure(startInfo, workingDirectory);
}
else if (environment.IsMac)
{
// we need to create a temp bash script to set up the environment properly, because
// osx terminal app doesn't inherit the PATH env var and there's no way to pass it in

var envVarFile = NPath.GetTempFilename();
environment.FileSystem.WriteAllLines(envVarFile, new string[] { "cd $GHU_WORKINGDIR", "PATH=$GHU_FULLPATH:$PATH /bin/bash" });
Mono.Unix.Native.Syscall.chmod(envVarFile, (Mono.Unix.Native.FilePermissions)493); // -rwxr-xr-x mode (0755)
startInfo.FileName = "open";
startInfo.Arguments = $"-a Terminal {envVarFile}";
gitEnvironment.Configure(startInfo, workingDirectory);

var envVars = startInfo.EnvironmentVariables;
var scriptContents = new[] {
$"cd {envVars["GHU_WORKINGDIR"]}",
$"PATH={envVars["GHU_FULLPATH"]}:$PATH /bin/bash"
};
environment.FileSystem.WriteAllLines(envVarFile, scriptContents);
Mono.Unix.Native.Syscall.chmod(envVarFile, (Mono.Unix.Native.FilePermissions)493); // -rwxr-xr-x mode (0755)
}
else
{
startInfo.FileName = "sh";
gitEnvironment.Configure(startInfo, workingDirectory);
}

gitEnvironment.Configure(startInfo, workingDirectory);
Process.Start(startInfo);
}

Expand Down