diff --git a/mpw/environment.rl b/mpw/environment.rl index 6e9a7d7..233889e 100644 --- a/mpw/environment.rl +++ b/mpw/environment.rl @@ -34,7 +34,7 @@ namespace MPW { extern std::unordered_map Environment; - std::string ExpandVariables(const std::string &s); + std::string ExpandVariables(const std::string &s, bool pathname = false); } namespace { @@ -102,11 +102,17 @@ namespace { }; # backwards compatibility. + # lcc generates temporary files named $xxx$ + # so don't replace in pathnames. '$' [A-Za-z0-9_]+ { - std::string name(ts + 1, te); - auto iter = Environment.find(name); - if (iter != Environment.end()) - rv.append(iter->second); + if (pathname) { + rv.append(ts, te); + } else { + std::string name(ts + 1, te); + auto iter = Environment.find(name); + if (iter != Environment.end()) + rv.append(iter->second); + } }; any { @@ -215,7 +221,7 @@ namespace MPW { return iter->second; } - std::string ExpandVariables(const std::string &s) + std::string ExpandVariables(const std::string &s, bool pathname) { if (s.find_first_of("{$") == s.npos) return s; diff --git a/mpw/mpw.h b/mpw/mpw.h index 2c3d306..94b0a6d 100644 --- a/mpw/mpw.h +++ b/mpw/mpw.h @@ -97,7 +97,7 @@ namespace MPW { std::string RootDirPathForFile(const std::string &file); std::string GetEnv(const std::string &); - std::string ExpandVariables(const std::string &s); + std::string ExpandVariables(const std::string &s, bool pathname = false); // should add argc/argv/envp... diff --git a/toolbox/pathnames.rl b/toolbox/pathnames.rl index 25630ae..96c9a5e 100644 --- a/toolbox/pathnames.rl +++ b/toolbox/pathnames.rl @@ -127,7 +127,7 @@ namespace ToolBox #ifndef TESTING if (path.find_first_of("${") != path.npos) { - path = MPW::ExpandVariables(path); + path = MPW::ExpandVariables(path, true); } #endif