summaryrefslogtreecommitdiff
path: root/src/plugins/remotelinux
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2019-06-04 15:59:30 +0200
committerhjk <hjk@qt.io>2019-06-05 13:03:47 +0000
commit2591d02fef9392dcb489725dde29d0fc0ff481d7 (patch)
tree21952c57db49050948014570e49d0c96188d2309 /src/plugins/remotelinux
parent1ce6c4abc37af3ab08cd3a5794ff1f3aece9a9c4 (diff)
downloadqt-creator-2591d02fef9392dcb489725dde29d0fc0ff481d7.tar.gz
RemoteLinux: Use Util::CommandLine to construct device process commands
Change-Id: I194b5225f56cabd92e1de7d3df2e74b515aa476e Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/remotelinux')
-rw-r--r--src/plugins/remotelinux/linuxdeviceprocess.cpp54
-rw-r--r--src/plugins/remotelinux/linuxdeviceprocess.h2
2 files changed, 26 insertions, 30 deletions
diff --git a/src/plugins/remotelinux/linuxdeviceprocess.cpp b/src/plugins/remotelinux/linuxdeviceprocess.cpp
index 00bd28b6e5..ca08b44ec9 100644
--- a/src/plugins/remotelinux/linuxdeviceprocess.cpp
+++ b/src/plugins/remotelinux/linuxdeviceprocess.cpp
@@ -28,15 +28,12 @@
#include <projectexplorer/runcontrol.h>
#include <utils/environment.h>
-#include <utils/qtcprocess.h>
using namespace ProjectExplorer;
using namespace Utils;
namespace RemoteLinux {
-static QString quote(const QString &s) { return Utils::QtcProcess::quoteArgUnix(s); }
-
LinuxDeviceProcess::LinuxDeviceProcess(const QSharedPointer<const ProjectExplorer::IDevice> &device,
QObject *parent)
: ProjectExplorer::SshDeviceProcess(device, parent), m_processId(0)
@@ -78,42 +75,41 @@ qint64 LinuxDeviceProcess::processId() const
QString LinuxDeviceProcess::fullCommandLine(const Runnable &runnable) const
{
- const Environment env = runnable.environment;
+ CommandLine cmd;
- QString fullCommandLine;
- foreach (const QString &filePath, rcFilesToSource())
- fullCommandLine += QString::fromLatin1("test -f %1 && . %1;").arg(filePath);
- if (!runnable.workingDirectory.isEmpty()) {
- fullCommandLine.append(QLatin1String("cd ")).append(quote(runnable.workingDirectory))
- .append(QLatin1String(" && "));
+ for (const QString &filePath : rcFilesToSource()) {
+ cmd.addArgs({"test", "-f", filePath});
+ cmd.addArgs("&&");
+ cmd.addArgs({".", filePath});
+ cmd.addArgs(";");
}
- QString envString;
- for (auto it = env.constBegin(); it != env.constEnd(); ++it) {
- if (!envString.isEmpty())
- envString += QLatin1Char(' ');
- envString.append(env.key(it)).append(QLatin1String("='")).append(env.value(it))
- .append(QLatin1Char('\''));
+
+ if (!runnable.workingDirectory.isEmpty()) {
+ cmd.addArgs({"cd", runnable.workingDirectory});
+ cmd.addArgs("&&");
}
+
if (!runInTerminal())
- fullCommandLine.append("echo $$ && ");
- if (!envString.isEmpty())
- fullCommandLine.append(envString);
+ cmd.addArgs("echo $$ && ");
+
+ const Environment &env = runnable.environment;
+ for (auto it = env.constBegin(); it != env.constEnd(); ++it)
+ cmd.addArgs(env.key(it) + "='" + env.value(it) + '\'');
+
if (!runInTerminal())
- fullCommandLine.append(" exec");
- fullCommandLine.append(' ');
- fullCommandLine.append(quote(runnable.executable));
- if (!runnable.commandLineArguments.isEmpty()) {
- fullCommandLine.append(QLatin1Char(' '));
- fullCommandLine.append(runnable.commandLineArguments);
- }
- return fullCommandLine;
+ cmd.addArg("exec");
+
+ cmd.addArg(runnable.executable);
+ cmd.addArgs(runnable.commandLineArguments);
+
+ return cmd.arguments();
}
-QStringList LinuxDeviceProcess::rcFilesToSource() const
+const QStringList LinuxDeviceProcess::rcFilesToSource() const
{
if (!m_rcFilesToSource.isEmpty())
return m_rcFilesToSource;
- return QStringList() << QLatin1String("/etc/profile") << QLatin1String("$HOME/.profile");
+ return {"/etc/profile", "$HOME/.profile"};
}
} // namespace RemoteLinux
diff --git a/src/plugins/remotelinux/linuxdeviceprocess.h b/src/plugins/remotelinux/linuxdeviceprocess.h
index 4b565029cc..b917222018 100644
--- a/src/plugins/remotelinux/linuxdeviceprocess.h
+++ b/src/plugins/remotelinux/linuxdeviceprocess.h
@@ -49,7 +49,7 @@ private:
QString fullCommandLine(const ProjectExplorer::Runnable &) const override;
qint64 processId() const override;
- QStringList rcFilesToSource() const;
+ const QStringList rcFilesToSource() const;
QStringList m_rcFilesToSource;
QByteArray m_processIdString;