From c36b1e40b0db99c5f9903cfb0aa614842c210b38 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 23 Jul 2019 15:44:13 +0200 Subject: [PATCH] Ssh: Use Utils::CommandLine in SshRemoteProcess Change-Id: I074ca3e1e8ec8ce990d6b314a4a87de2f656566c Reviewed-by: Christian Kandeler --- src/libs/ssh/sshremoteprocess.cpp | 28 +++++++++++-------- src/libs/ssh/sshremoteprocess.h | 4 +-- .../devicesupport/sshdeviceprocess.cpp | 3 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/libs/ssh/sshremoteprocess.cpp b/src/libs/ssh/sshremoteprocess.cpp index 635f23e1503..3d1ef6a81e0 100644 --- a/src/libs/ssh/sshremoteprocess.cpp +++ b/src/libs/ssh/sshremoteprocess.cpp @@ -83,15 +83,14 @@ SshRemoteProcess::SshRemoteProcess(const QString &command, const QStringList &co void SshRemoteProcess::doStart() { QTC_ASSERT(!isRunning(), return); - const QStringList args = fullLocalCommandLine(); + const Utils::CommandLine cmd = fullLocalCommandLine(); if (!d->displayName.isEmpty()) { QProcessEnvironment env = processEnvironment(); env.insert("DISPLAY", d->displayName); setProcessEnvironment(env); } - qCDebug(sshLog) << "starting remote process:" << QDir::toNativeSeparators(args.first()) - << args; - QProcess::start(args.first(), args.mid(1)); + qCDebug(sshLog) << "starting remote process:" << cmd.toUserOutput(); + QProcess::start(cmd.executable().toString(), cmd.splitArguments()); } SshRemoteProcess::~SshRemoteProcess() @@ -119,17 +118,22 @@ bool SshRemoteProcess::isRunning() const return state() == QProcess::Running; } -QStringList SshRemoteProcess::fullLocalCommandLine() const +Utils::CommandLine SshRemoteProcess::fullLocalCommandLine() const { - QStringList args = QStringList("-q") << d->connectionArgs; - if (d->useTerminal) - args.prepend("-tt"); + Utils::CommandLine cmd{SshSettings::sshFilePath()}; + 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()) - args << d->remoteCommand; - args.prepend(SshSettings::sshFilePath().toString()); - return args; + cmd.addArg(d->remoteCommand); + + return cmd; } } // namespace QSsh diff --git a/src/libs/ssh/sshremoteprocess.h b/src/libs/ssh/sshremoteprocess.h index 02ab3546fdc..d1d62d76fad 100644 --- a/src/libs/ssh/sshremoteprocess.h +++ b/src/libs/ssh/sshremoteprocess.h @@ -28,7 +28,7 @@ #include "ssh_global.h" #include "sshprocess.h" -#include +#include namespace QSsh { class SshConnection; @@ -46,7 +46,7 @@ public: void start(); bool isRunning() const; - QStringList fullLocalCommandLine() const; + Utils::CommandLine fullLocalCommandLine() const; signals: void done(const QString &error); diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp index 19ca79d0c2f..56fd1b9503d 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp @@ -194,7 +194,6 @@ void SshDeviceProcess::handleConnected() d->process->requestX11Forwarding(display); if (runInTerminal()) { d->process->requestTerminal(); - const QStringList cmdLine = d->process->fullLocalCommandLine(); connect(&d->consoleProcess, QOverload::of(&ConsoleProcess::error), this, &DeviceProcess::error); connect(&d->consoleProcess, &ConsoleProcess::processStarted, @@ -202,7 +201,7 @@ void SshDeviceProcess::handleConnected() connect(&d->consoleProcess, &ConsoleProcess::stubStopped, this, [this] { handleProcessFinished(d->consoleProcess.errorString()); }); d->consoleProcess.setAbortOnMetaChars(false); - d->consoleProcess.setCommand({cmdLine.first(), cmdLine.mid(1)}); + d->consoleProcess.setCommand(d->process->fullLocalCommandLine()); d->consoleProcess.start(); } else { connect(d->process.get(), &QSsh::SshRemoteProcess::started,