From 1eeefa1bef74d0394b3d46dbda7a4da7873e427c Mon Sep 17 00:00:00 2001 From: con <qtc-committer@nokia.com> Date: Mon, 13 Dec 2010 19:04:16 +0100 Subject: [PATCH] Split argument list correctly. Makes "Edit in vi" work on Linux. It now follows quoting rules. --- share/qtcreator/externaltools/vi.xml | 2 +- src/plugins/coreplugin/externaltool.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/share/qtcreator/externaltools/vi.xml b/share/qtcreator/externaltools/vi.xml index 63d8908a3eb..792401c0717 100644 --- a/share/qtcreator/externaltools/vi.xml +++ b/share/qtcreator/externaltools/vi.xml @@ -38,7 +38,7 @@ <category xml:lang="de">Text</category> <executable output="reloaddocument"> <path>xterm</path> - <arguments>-geom %{CurrentDocument:Width}x%{CurrentDocument:Height}+%{CurrentDocument:XPos}+%{CurrentDocument:YPos} -e vi \"%{CurrentDocument:FilePath}\" +%{CurrentDocument:Row} +"normal %{CurrentDocument:Column}|"</arguments> + <arguments>-geom %{CurrentDocument:ColumnCount}x%{CurrentDocument:RowCount}+%{CurrentDocument:XPos}+%{CurrentDocument:YPos} -e vi "%{CurrentDocument:FilePath}" +%{CurrentDocument:Row} +"normal %{CurrentDocument:Column}|"</arguments> <workingdirectory>%{CurrentDocument:Path}</workingdirectory> </executable> </externaltool> diff --git a/src/plugins/coreplugin/externaltool.cpp b/src/plugins/coreplugin/externaltool.cpp index 1de759c38b0..46651bf2f15 100644 --- a/src/plugins/coreplugin/externaltool.cpp +++ b/src/plugins/coreplugin/externaltool.cpp @@ -42,6 +42,7 @@ #include <utils/qtcassert.h> #include <utils/stringutils.h> #include <utils/environment.h> +#include <utils/qtcprocess.h> #include <QtCore/QXmlStreamReader> #include <QtCore/QDir> @@ -314,8 +315,13 @@ bool ExternalToolRunner::resolve() { // arguments QString resolved = Utils::expandMacros(m_tool->arguments(), Core::VariableManager::instance()->macroExpander()); - // TODO stupid, do it right - m_resolvedArguments = resolved.split(QLatin1Char(' '), QString::SkipEmptyParts); + // handle quoting in the command line arguments etc + QString cmd; + Utils::QtcProcess::prepareCommand(m_resolvedExecutable, resolved, + &cmd, &m_resolvedArguments); + if (cmd.isEmpty()) + return false; + m_resolvedExecutable = cmd; } { // input m_resolvedInput = Utils::expandMacros(m_tool->input(), @@ -357,6 +363,8 @@ void ExternalToolRunner::run() m_process->setWorkingDirectory(m_resolvedWorkingDirectory); ICore::instance()->messageManager()->printToOutputPane( tr("Starting external tool '%1'").arg(m_resolvedExecutable), false); + ICore::instance()->messageManager()->printToOutputPane( + tr("with arguments (%1)").arg(m_resolvedArguments.join(QLatin1String(", "))), false); m_process->start(m_resolvedExecutable, m_resolvedArguments, QIODevice::ReadWrite); } -- GitLab