Substitute tilde with USERPROFILE on Windows

The substitution is now more shell-like and tilde is only replaced
from the beginning of the path if it is trailed by a slash.
This commit is contained in:
Toni Spets
2020-07-17 19:36:24 +03:00
committed by Jonathan White
parent 005d9d368f
commit 7c39907251
2 changed files with 9 additions and 1 deletions

View File

@@ -331,11 +331,15 @@ namespace Tools
#if defined(Q_OS_WIN)
QRegularExpression varRe("\\%([A-Za-z][A-Za-z0-9_]*)\\%");
QString homeEnv = "USERPROFILE";
#else
QRegularExpression varRe("\\$([A-Za-z][A-Za-z0-9_]*)");
subbed.replace("~", environment.value("HOME"));
QString homeEnv = "HOME";
#endif
if (subbed.startsWith("~/") || subbed.startsWith("~\\"))
subbed.replace(0, 1, environment.value(homeEnv));
QRegularExpressionMatch match;
do {