diff --git a/src/libs/utils/commandline.cpp b/src/libs/utils/commandline.cpp index 946f4aa1c41..60b8d72eed2 100644 --- a/src/libs/utils/commandline.cpp +++ b/src/libs/utils/commandline.cpp @@ -1444,16 +1444,15 @@ CommandLine CommandLine::fromUserInput(const QString &cmdline, MacroExpander *ex QString input = cmdline.trimmed(); - QStringList result = ProcessArgs::splitArgs(cmdline, HostOsInfo::hostOs()); + if (expander) + input = expander->expand(input); + + const QStringList result = ProcessArgs::splitArgs(input, HostOsInfo::hostOs()); if (result.isEmpty()) return {}; - auto cmd = CommandLine(FilePath::fromUserInput(result.value(0)), result.mid(1)); - if (expander) - cmd.m_arguments = expander->expand(cmd.m_arguments); - - return cmd; + return {FilePath::fromUserInput(result.value(0)), result.mid(1)}; } void CommandLine::addArg(const QString &arg) diff --git a/tests/auto/utils/commandline/tst_commandline.cpp b/tests/auto/utils/commandline/tst_commandline.cpp index aebf7075128..c8b29ff6586 100644 --- a/tests/auto/utils/commandline/tst_commandline.cpp +++ b/tests/auto/utils/commandline/tst_commandline.cpp @@ -196,8 +196,7 @@ private slots: QTest::newRow("simple") << "command %{hello}" << "command" - << (HostOsInfo::isWindowsHost() ? "\"hello world\"" - : "'hello world'"); + << "hello world"; QTest::newRow("simple-quoted") << "command \"%{hello}\"" @@ -226,15 +225,11 @@ private slots: CommandLine cmd = CommandLine::fromUserInput(input, &expander); QCOMPARE(cmd.executable().toUserOutput(), expectedExecutable); - // TODO: Fix (macro) escaping on windows - if (HostOsInfo::isWindowsHost()) - QEXPECT_FAIL("simple", "Windows does not correctly quote macro arguments", Continue); - if (HostOsInfo::isWindowsHost()) - QEXPECT_FAIL("simple-quoted", "Windows removes quotes from macro arguments", Continue); - if (HostOsInfo::isWindowsHost()) + if (HostOsInfo::isWindowsHost()) { QEXPECT_FAIL("convert-to-quote-win", "Windows should convert single to double quotes", Continue); + } QCOMPARE(cmd.arguments(), expectedArguments); }