From 1e0d6084aff6c9dbeeec87cd3d5e239e2d119ea8 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 16 Jan 2025 17:39:50 +0100 Subject: [PATCH] Revert "Utils: Fix quoting on Linux" This reverts commit 97a37eb6fd, breaks tst_Process::iterations. The new tst_CommandLine::testMultiQuote_win() fails in the CI, too. Change-Id: I657b7bbf073a06a3175c88a25eba019dad2c830d Reviewed-by: Marcus Tillmanns --- src/libs/utils/commandline.cpp | 2 +- .../utils/commandline/tst_commandline.cpp | 42 ------------------- 2 files changed, 1 insertion(+), 43 deletions(-) diff --git a/src/libs/utils/commandline.cpp b/src/libs/utils/commandline.cpp index 69a08d319a2..0217d38fadf 100644 --- a/src/libs/utils/commandline.cpp +++ b/src/libs/utils/commandline.cpp @@ -516,7 +516,7 @@ QString ProcessArgs::quoteArgUnix(const QString &arg) if (arg == "&&" || arg == "||" || arg == "&" || arg == ';') return ret; - ret.replace(QLatin1Char('\''), QLatin1String(R"('"'"')")); + ret.replace(QLatin1Char('\''), QLatin1String("'\\''")); ret.prepend(QLatin1Char('\'')); ret.append(QLatin1Char('\'')); } diff --git a/tests/auto/utils/commandline/tst_commandline.cpp b/tests/auto/utils/commandline/tst_commandline.cpp index efb38a500b9..aca984adf54 100644 --- a/tests/auto/utils/commandline/tst_commandline.cpp +++ b/tests/auto/utils/commandline/tst_commandline.cpp @@ -72,48 +72,6 @@ private slots: QCOMPARE(run(cmd), expected); } - void testMultiQuote_unix() - { - CommandLine cmd("echo", {"This is a long argument"}, OsTypeLinux); - CommandLine outer("echo", {}, OsTypeLinux); - - outer.addCommandLineAsSingleArg(cmd, OsTypeLinux); - QCOMPARE(outer.toUserOutput(), R"(echo 'echo '"'"'This is a long argument'"'"'')"); - - CommandLine triple("echo", {}, OsTypeLinux); - QString expectedTriple - = R"(echo 'echo '"'"'echo '"'"'"'"'"'"'"'"'This is a long argument'"'"'"'"'"'"'"'"''"'"'')"; - - triple.addCommandLineAsSingleArg(outer, OsTypeLinux); - QCOMPARE(triple.toUserOutput(), expectedTriple); - } - - void testMultiQuote_win() - { - CommandLine cmd("echo", {"This is a long argument"}, OsTypeWindows); - CommandLine outer("echo", {}, OsTypeWindows); - - outer.addCommandLineAsSingleArg(cmd); - QCOMPARE(outer.toUserOutput(), R"(echo 'echo "This is a long argument"')"); - - CommandLine triple("echo", {}, OsTypeWindows); - triple.addCommandLineAsSingleArg(outer, OsTypeWindows); - QString expectedTriple = R"(echo "echo 'echo "\^""This is a long argument"\^""'")"; - QCOMPARE(triple.toUserOutput(), expectedTriple); - } - - void testMixedMultiQuote() - { - CommandLine - dockerExec("docker", {"exec", "not really an ID", "/bin/sh", "-c"}, OsTypeWindows); - CommandLine binsh("/bin/sh", {"-c", "echo 'Hello World'"}, OsTypeLinux); - - dockerExec.addCommandLineAsSingleArg(binsh, OsTypeLinux); - QString expected - = R"(docker exec "not really an ID" /bin/sh -c '/bin/sh -c '"'"'echo '"'"'"'"'"'"'"'"'Hello World'"'"'"'"'"'"'"'"''"'"'')"; - QCOMPARE(dockerExec.toUserOutput(), expected); - } - void testAnd() { QStringList args = {"foo", "bar", "baz"};