Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Merged
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
12 changes: 12 additions & 0 deletions src/GitHub.Api/IO/NiceIO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,18 @@ public static NPath CreateTempDirectory(string myprefix)
}
}

public static NPath GetTempFilename(string myprefix = "")
{
var random = new Random();
var prefix = FileSystem.GetTempPath() + "/" + (String.IsNullOrEmpty(myprefix) ? "" : myprefix + "_");
while (true)
{
var candidate = new NPath(prefix + random.Next());
if (!candidate.Exists())
return candidate;
}
}

public NPath Move(string dest)
{
return Move(new NPath(dest));
Expand Down
3 changes: 2 additions & 1 deletion src/GitHub.Api/OutputProcessors/ProcessManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public void RunCommandLineWindow(NPath workingDirectory)
{
// 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 = environment.FileSystem.GetRandomFileName();

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";
Expand Down