Ssh: Use Utils::CommandLine in SshRemoteProcess

Change-Id: I074ca3e1e8ec8ce990d6b314a4a87de2f656566c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-07-23 15:44:13 +02:00
parent fa81f76237
commit c36b1e40b0
3 changed files with 19 additions and 16 deletions

View File

@@ -83,15 +83,14 @@ SshRemoteProcess::SshRemoteProcess(const QString &command, const QStringList &co
void SshRemoteProcess::doStart() void SshRemoteProcess::doStart()
{ {
QTC_ASSERT(!isRunning(), return); QTC_ASSERT(!isRunning(), return);
const QStringList args = fullLocalCommandLine(); const Utils::CommandLine cmd = fullLocalCommandLine();
if (!d->displayName.isEmpty()) { if (!d->displayName.isEmpty()) {
QProcessEnvironment env = processEnvironment(); QProcessEnvironment env = processEnvironment();
env.insert("DISPLAY", d->displayName); env.insert("DISPLAY", d->displayName);
setProcessEnvironment(env); setProcessEnvironment(env);
} }
qCDebug(sshLog) << "starting remote process:" << QDir::toNativeSeparators(args.first()) qCDebug(sshLog) << "starting remote process:" << cmd.toUserOutput();
<< args; QProcess::start(cmd.executable().toString(), cmd.splitArguments());
QProcess::start(args.first(), args.mid(1));
} }
SshRemoteProcess::~SshRemoteProcess() SshRemoteProcess::~SshRemoteProcess()
@@ -119,17 +118,22 @@ bool SshRemoteProcess::isRunning() const
return state() == QProcess::Running; return state() == QProcess::Running;
} }
QStringList SshRemoteProcess::fullLocalCommandLine() const Utils::CommandLine SshRemoteProcess::fullLocalCommandLine() const
{ {
QStringList args = QStringList("-q") << d->connectionArgs; Utils::CommandLine cmd{SshSettings::sshFilePath()};
if (d->useTerminal)
args.prepend("-tt");
if (!d->displayName.isEmpty()) if (!d->displayName.isEmpty())
args.prepend("-X"); cmd.addArg("-X");
if (d->useTerminal)
cmd.addArg("-tt");
cmd.addArg("-q");
cmd.addArgs(d->connectionArgs);
if (!d->remoteCommand.isEmpty()) if (!d->remoteCommand.isEmpty())
args << d->remoteCommand; cmd.addArg(d->remoteCommand);
args.prepend(SshSettings::sshFilePath().toString());
return args; return cmd;
} }
} // namespace QSsh } // namespace QSsh

View File

@@ -28,7 +28,7 @@
#include "ssh_global.h" #include "ssh_global.h"
#include "sshprocess.h" #include "sshprocess.h"
#include <QStringList> #include <utils/fileutils.h>
namespace QSsh { namespace QSsh {
class SshConnection; class SshConnection;
@@ -46,7 +46,7 @@ public:
void start(); void start();
bool isRunning() const; bool isRunning() const;
QStringList fullLocalCommandLine() const; Utils::CommandLine fullLocalCommandLine() const;
signals: signals:
void done(const QString &error); void done(const QString &error);

View File

@@ -194,7 +194,6 @@ void SshDeviceProcess::handleConnected()
d->process->requestX11Forwarding(display); d->process->requestX11Forwarding(display);
if (runInTerminal()) { if (runInTerminal()) {
d->process->requestTerminal(); d->process->requestTerminal();
const QStringList cmdLine = d->process->fullLocalCommandLine();
connect(&d->consoleProcess, QOverload<QProcess::ProcessError>::of(&ConsoleProcess::error), connect(&d->consoleProcess, QOverload<QProcess::ProcessError>::of(&ConsoleProcess::error),
this, &DeviceProcess::error); this, &DeviceProcess::error);
connect(&d->consoleProcess, &ConsoleProcess::processStarted, connect(&d->consoleProcess, &ConsoleProcess::processStarted,
@@ -202,7 +201,7 @@ void SshDeviceProcess::handleConnected()
connect(&d->consoleProcess, &ConsoleProcess::stubStopped, connect(&d->consoleProcess, &ConsoleProcess::stubStopped,
this, [this] { handleProcessFinished(d->consoleProcess.errorString()); }); this, [this] { handleProcessFinished(d->consoleProcess.errorString()); });
d->consoleProcess.setAbortOnMetaChars(false); d->consoleProcess.setAbortOnMetaChars(false);
d->consoleProcess.setCommand({cmdLine.first(), cmdLine.mid(1)}); d->consoleProcess.setCommand(d->process->fullLocalCommandLine());
d->consoleProcess.start(); d->consoleProcess.start();
} else { } else {
connect(d->process.get(), &QSsh::SshRemoteProcess::started, connect(d->process.get(), &QSsh::SshRemoteProcess::started,