Browse Source

Use single quote escape for RunBashCommand

pull/55/head
Ionite 1 year ago
parent
commit
b764b50ebd
No known key found for this signature in database
  1. 4
      StabilityMatrix.Core/Processes/ProcessRunner.cs

4
StabilityMatrix.Core/Processes/ProcessRunner.cs

@ -230,7 +230,9 @@ public static class ProcessRunner
public static async Task<ProcessResult> RunBashCommand(string command, string workingDirectory = "")
{
var processInfo = new ProcessStartInfo("bash", "-c \"" + command + "\"")
// Escape any single quotes in the command
var escapedCommand = command.Replace("'", "\\'");
var processInfo = new ProcessStartInfo("bash", $"-c '{escapedCommand}'")
{
UseShellExecute = false,
RedirectStandardOutput = true,

Loading…
Cancel
Save