forked from qt-creator/qt-creator
Utils: Use Utils::CommandLine as input for ProcessArgs::prepareCommand
Change-Id: Ib5878a159bda0e6b6253f1f4e1abc1acb5ecb573 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -643,20 +643,20 @@ void ProcessArgs::addArgs(QString *args, const QStringList &inArgs)
|
||||
addArg(args, arg);
|
||||
}
|
||||
|
||||
bool ProcessArgs::prepareCommand(const QString &command, const QString &arguments,
|
||||
QString *outCmd, ProcessArgs *outArgs, OsType osType,
|
||||
bool ProcessArgs::prepareCommand(const CommandLine &cmdLine, QString *outCmd, ProcessArgs *outArgs,
|
||||
const Environment *env, const FilePath *pwd)
|
||||
{
|
||||
const FilePath executable = cmdLine.executable();
|
||||
const QString arguments = cmdLine.arguments();
|
||||
ProcessArgs::SplitError err;
|
||||
*outArgs = ProcessArgs::prepareArgs(arguments, &err, osType, env, pwd);
|
||||
*outArgs = ProcessArgs::prepareArgs(arguments, &err, executable.osType(), env, pwd);
|
||||
if (err == ProcessArgs::SplitOk) {
|
||||
*outCmd = command;
|
||||
*outCmd = executable.toString();
|
||||
} else {
|
||||
if (osType == OsTypeWindows) {
|
||||
if (executable.osType() == OsTypeWindows) {
|
||||
*outCmd = QString::fromLatin1(qgetenv("COMSPEC"));
|
||||
*outArgs = ProcessArgs::createWindowsArgs(QLatin1String("/v:off /s /c \"")
|
||||
+ quoteArg(QDir::toNativeSeparators(command)) + QLatin1Char(' ') + arguments
|
||||
+ QLatin1Char('"'));
|
||||
+ quoteArg(executable.toUserOutput()) + ' ' + arguments + '"');
|
||||
} else {
|
||||
if (err != ProcessArgs::FoundMeta)
|
||||
return false;
|
||||
@@ -667,8 +667,7 @@ bool ProcessArgs::prepareCommand(const QString &command, const QString &argument
|
||||
*outCmd = qEnvironmentVariableIsSet("SHELL") ? QString::fromLocal8Bit(qgetenv("SHELL"))
|
||||
: QString("/bin/sh");
|
||||
#endif
|
||||
*outArgs = ProcessArgs::createUnixArgs(
|
||||
QStringList({"-c", (quoteArg(command) + ' ' + arguments)}));
|
||||
*outArgs = ProcessArgs::createUnixArgs({"-c", quoteArg(executable.toString()) + ' ' + arguments});
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@@ -35,6 +35,7 @@
|
||||
namespace Utils {
|
||||
|
||||
class AbstractMacroExpander;
|
||||
class CommandLine;
|
||||
class Environment;
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT ProcessArgs
|
||||
@@ -67,8 +68,7 @@ public:
|
||||
const Environment *env = nullptr, const FilePath *pwd = nullptr,
|
||||
bool abortOnMeta = true);
|
||||
//! Prepare a shell command for feeding into QProcess
|
||||
static bool prepareCommand(const QString &command, const QString &arguments,
|
||||
QString *outCmd, ProcessArgs *outArgs, OsType osType = HostOsInfo::hostOs(),
|
||||
static bool prepareCommand(const CommandLine &cmdLine, QString *outCmd, ProcessArgs *outArgs,
|
||||
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);
|
||||
|
@@ -579,7 +579,6 @@ void QtcProcess::start()
|
||||
}
|
||||
|
||||
Environment env;
|
||||
const OsType osType = HostOsInfo::hostOs();
|
||||
if (d->m_haveEnv) {
|
||||
if (d->m_environment.size() == 0)
|
||||
qWarning("QtcProcess::start: Empty environment set when running '%s'.",
|
||||
@@ -595,11 +594,10 @@ void QtcProcess::start()
|
||||
|
||||
QString command;
|
||||
ProcessArgs arguments;
|
||||
bool success = ProcessArgs::prepareCommand(d->m_commandLine.executable().toString(),
|
||||
d->m_commandLine.arguments(),
|
||||
&command, &arguments, osType, &env,
|
||||
bool success = ProcessArgs::prepareCommand(d->m_commandLine, &command, &arguments, &env,
|
||||
&d->m_workingDirectory);
|
||||
if (osType == OsTypeWindows) {
|
||||
|
||||
if (d->m_commandLine.executable().osType() == OsTypeWindows) {
|
||||
QString args;
|
||||
if (d->m_useCtrlCStub) {
|
||||
if (d->m_process->lowPriority())
|
||||
|
Reference in New Issue
Block a user