Skip to content

Commit f92c08f

Browse files
committed
Update TerminalLauncher.cs
1 parent 15d1721 commit f92c08f

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

MCPForUnity/Editor/Services/Server/TerminalLauncher.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,13 @@ public System.Diagnostics.ProcessStartInfo CreateTerminalProcessStartInfo(string
7070
CreateNoWindow = true
7171
};
7272
#else
73-
// Linux: Try common terminal emulators
74-
// We use bash -c to execute the command, so we must properly quote/escape for bash
75-
// Escape single quotes for the inner bash string
76-
string escapedCommandLinux = command.Replace("'", "'\\''");
77-
// Wrap the command in single quotes for bash -c
78-
string script = $"'{escapedCommandLinux}; exec bash'";
79-
// Escape double quotes for the outer Process argument string
80-
string escapedScriptForArg = script.Replace("\"", "\\\"");
73+
// Linux: Try common terminal emulators.
74+
// ProcessStartInfo passes the argument string directly to the terminal, so we only
75+
// need to escape for the double-quoted bash -c payload — no inner single quotes.
76+
string script = $"{command}; exec bash";
77+
string escapedScriptForArg = script
78+
.Replace("\\", "\\\\")
79+
.Replace("\"", "\\\"");
8180
string bashCmdArgs = $"bash -c \"{escapedScriptForArg}\"";
8281

8382
string[] terminals = { "gnome-terminal", "xterm", "konsole", "xfce4-terminal" };

0 commit comments

Comments
 (0)