Fix crash when env vars contain utf8 chars

This commit is contained in:
Dave Thomas 2013-06-22 21:41:04 -05:00
parent 934ec7fdef
commit dd277fd01a

View file

@ -191,12 +191,12 @@ expand_env_variable(InStr, VarName, RawVarValue) ->
%% No variables to expand
InStr;
_ ->
VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", [global, unicode]),
ReOpts = [global, unicode],
VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", ReOpts),
%% Use a regex to match/replace:
%% Given variable "FOO": match $FOO\s | $FOOeol | ${FOO}
RegEx = io_lib:format("\\\$(~s(\\s|$)|{~s})", [VarName, VarName]),
ReOpts = [global, {return, list}, unicode],
re:replace(InStr, RegEx, [VarValue, "\\2"], ReOpts)
re:replace(InStr, RegEx, [VarValue, "\\2"], ReOpts ++ [{return, list}])
end.
vcs_vsn(Config, Vcs, Dir) ->