kdecore: check if the dollar sign is used for command in KShellTest::envExpand()

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-10-16 19:54:51 +03:00
parent b5c25aa63b
commit af07c63a89
2 changed files with 5 additions and 1 deletions

View file

@ -60,6 +60,8 @@ KShellTest::envExpand()
QCOMPARE(KShell::envExpand("${HOME}/${LOGNAME}"), QString(QDir::homePath()+"/" + me));
QCOMPARE(KShell::envExpand("\\${HOME}/${LOGNAME}"), QString("\\${HOME}/" + me));
QCOMPARE(KShell::envExpand("${HOME}/\\${LOGNAME}"), QString(QDir::homePath()+"/\\${LOGNAME}"));
QCOMPARE(KShell::envExpand("$(hostname)"), QString("$(hostname)"));
}
void

View file

@ -79,7 +79,9 @@ QString KShell::envExpand( const QString &fname )
QString result = fname;
int i = 0;
while (i < result.size()) {
if (result.at(i) == QLatin1Char('$') && result[i - 1] != QLatin1Char('\\')) {
if (result.at(i) == QLatin1Char('$')
&& result[i - 1] != QLatin1Char('\\')
&& result[i + 1] != QLatin1Char('(')) {
int varstart = i + 1;
int varend = varstart;
int varlen = 0;