diff --git a/src/libs/utils/commandline.cpp b/src/libs/utils/commandline.cpp index 1da60c3565c..0217d38fadf 100644 --- a/src/libs/utils/commandline.cpp +++ b/src/libs/utils/commandline.cpp @@ -628,6 +628,12 @@ void ProcessArgs::addArgs(QString *args, const QStringList &inArgs) addArg(args, arg); } +void ProcessArgs::addArgs(QString *args, const QStringList &inArgs, OsType osType) +{ + for (const QString &arg : inArgs) + addArg(args, arg, osType); +} + CommandLine &CommandLine::operator<<(const QString &arg) { addArg(arg); @@ -1543,6 +1549,15 @@ void CommandLine::addCommandLineAsSingleArg(const CommandLine &cmd) addArg(combined); } +void CommandLine::addCommandLineAsSingleArg(const CommandLine &cmd, OsType osType) +{ + QString combined; + ProcessArgs::addArg(&combined, cmd.executable().path(), osType); + ProcessArgs::addArgs(&combined, cmd.arguments()); + + addArg(combined, osType); +} + void CommandLine::addCommandLineWithAnd(const CommandLine &cmd) { if (m_executable.isEmpty()) { diff --git a/src/libs/utils/commandline.h b/src/libs/utils/commandline.h index 78f756a9f61..22731264c3d 100644 --- a/src/libs/utils/commandline.h +++ b/src/libs/utils/commandline.h @@ -53,6 +53,8 @@ public: const Environment *env = nullptr, const FilePath *pwd = nullptr); //! Quote and append each argument to a shell command static void addArgs(QString *args, const QStringList &inArgs); + //! Quote and append each argument to a shell command + static void addArgs(QString *args, const QStringList &inArgs, OsType osType); //! Append already quoted arguments to a shell command static void addArgs(QString *args, const QString &inArgs); //! Split a shell command into separate arguments. @@ -170,6 +172,7 @@ public: void addCommandLineAsArgs(const CommandLine &cmd, RawType); void addCommandLineAsSingleArg(const CommandLine &cmd); + void addCommandLineAsSingleArg(const CommandLine &cmd, OsType osType); void addCommandLineWithAnd(const CommandLine &cmd); QString toUserOutput() const;