Utils::Environment: Use expanded values

The Environment class is supposed to support values with references to
other variables, but we failed to actually expand them in most places.

Fixes: QTCREATORBUG-22687
Change-Id: I108cb59d3b4571471423455240f6f4f1cf64bf05
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2019-08-19 14:29:14 +02:00
parent 30dc401429
commit 6d3f236aab
19 changed files with 58 additions and 26 deletions

View File

@@ -94,7 +94,7 @@ static void envExpandWin(QString &args, const Environment *env, const QString *p
if (prev >= 0) {
const QString var = args.mid(prev + 1, that - prev - 1).toUpper();
const QString val = (var == cdName && pwd && !pwd->isEmpty())
? QDir::toNativeSeparators(*pwd) : env->value(var);
? QDir::toNativeSeparators(*pwd) : env->expandedValueForKey(var);
if (!val.isEmpty()) { // Empty values are impossible, so this is an existence check
args.replace(prev, that - prev + 1, val);
off = prev + val.length();
@@ -394,7 +394,7 @@ static QStringList splitArgsUnix(const QString &args, bool abortOnMeta,
if (abortOnMeta)
goto metaerr; // Assume this is a shell builtin
} else {
cret += env->value(vit);
cret += env->expandedValueForKey(env->key(vit));
}
}
if (!braced)
@@ -444,7 +444,7 @@ static QStringList splitArgsUnix(const QString &args, bool abortOnMeta,
if (abortOnMeta)
goto metaerr; // Assume this is a shell builtin
} else {
val = env->value(vit);
val = env->expandedValueForKey(env->key(vit));
}
}
for (int i = 0; i < val.length(); i++) {
@@ -698,7 +698,7 @@ void QtcProcess::start()
qPrintable(m_commandLine.executable().toString()));
env = m_environment;
QProcess::setEnvironment(env.toStringList());
QProcess::setProcessEnvironment(env.toProcessEnvironment());
} else {
env = Environment::systemEnvironment();
}