From 150635107eba8c43c3fcb1ae6e34f39fa73df00e Mon Sep 17 00:00:00 2001 From: KingToolbox Date: Sat, 19 Sep 2020 01:07:12 +0800 Subject: [PATCH] [BugFix] WinPty can not launch applications with spaces in the path. --- src/Pty/WinPty.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Pty/WinPty.cpp b/src/Pty/WinPty.cpp index 0a0d9bb..d1cbde6 100644 --- a/src/Pty/WinPty.cpp +++ b/src/Pty/WinPty.cpp @@ -54,8 +54,19 @@ bool WinPty::createProcess(QString command, const QString &arguments, errorString = tr("Winpty-agent.exe or winpty.dll not found!."); break; } + command = command.trimmed(); + + if (command.startsWith("\"") && command.endsWith("\"")) { + command.remove(command.length() - 1, 1); + command.remove(0, 1); + } + QString commandWithArguments = command; + if (commandWithArguments.contains(' ')) { + commandWithArguments.prepend("\"").append("\""); + } + if (arguments.isEmpty() == false) { commandWithArguments.append(" ").append(arguments); }