1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-30 02:55:45 +01:00

expand brace notation (${VAR}) environment variables in pathnames

This commit is contained in:
Doug Kearns
2008-10-18 14:21:21 +00:00
parent 0dab4f86cf
commit 4d8ab3530e

View File

@@ -426,20 +426,12 @@ function IO() //{{{
path = path.replace("~", home); path = path.replace("~", home);
} }
// expand any $ENV vars // expand any $ENV vars - this is naive but so is Vim and we like to be compatible
var envVars = path.match(/\$\w+\b/g); // this is naive but so is Vim and we like to be compatible // TODO: Vim does not expand variables set to an empty string - are we just matching a bug?
path = path.replace(
if (envVars) /\$(?:{\w+}|\w+\b)/g,
{ function (v) environmentService.get(v.replace(/\${?(\w+)}?/, "$1")) || v
var expansion; );
for (let i = 0; i < envVars.length; i++)
{
expansion = environmentService.get(envVars[i].replace("$", ""));
if (expansion)
path = path.replace(envVars[i], expansion);
}
}
return path; return path;
}, },