Utils: Add "addCommandLine..." functions

addCommandLineAsSingleArg allows to reliably create commandlines
like "bash -c 'echo ...'"

addCommandLineWithAnd combines two command lines
by adding '&&' in between

Change-Id: Ic5af34c90fd5271dced40ba1341a3df019ededb8
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2022-11-22 08:35:43 +01:00
parent b1df55426a
commit 3e6c3d9fe7
7 changed files with 101 additions and 1 deletions

View File

@@ -1473,6 +1473,26 @@ void CommandLine::addCommandLineAsArgs(const CommandLine &cmd, RawType)
addArgs(cmd.arguments(), Raw);
}
void CommandLine::addCommandLineAsSingleArg(const CommandLine &cmd)
{
QString combined;
ProcessArgs::addArg(&combined, cmd.executable().path());
ProcessArgs::addArgs(&combined, cmd.arguments());
addArg(combined);
}
void CommandLine::addCommandLineWithAnd(const CommandLine &cmd)
{
if (m_executable.isEmpty()) {
*this = cmd;
return;
}
addArgs("&&", Raw);
addCommandLineAsArgs(cmd);
}
void CommandLine::addArgs(const QString &inArgs, RawType)
{
ProcessArgs::addArgs(&m_arguments, inArgs);