Merge pull request #26 from l4u/patch-1

Support environment vars with unicode characters
This commit is contained in:
Dave Smith 2012-12-02 09:52:29 -08:00
commit 71c717d86b

View file

@ -399,7 +399,7 @@ expand_vars_loop([], Recurse, Vars, Count) ->
expand_vars_loop(Recurse, [], Vars, Count-1); expand_vars_loop(Recurse, [], Vars, Count-1);
expand_vars_loop([{K, V} | Rest], Recurse, Vars, Count) -> expand_vars_loop([{K, V} | Rest], Recurse, Vars, Count) ->
%% Identify the variables that need expansion in this value %% Identify the variables that need expansion in this value
ReOpts = [global, {capture, all_but_first, list}], ReOpts = [global, {capture, all_but_first, list}, unicode],
case re:run(V, "\\\${?(\\w+)}?", ReOpts) of case re:run(V, "\\\${?(\\w+)}?", ReOpts) of
{match, Matches} -> {match, Matches} ->
%% Identify the unique variables that need to be expanded %% Identify the unique variables that need to be expanded
@ -472,8 +472,8 @@ erts_dir() ->
lists:concat([code:root_dir(), "/erts-", erlang:system_info(version)]). lists:concat([code:root_dir(), "/erts-", erlang:system_info(version)]).
os_env() -> os_env() ->
Os = [list_to_tuple(re:split(S, "=", [{return, list}, {parts, 2}])) || ReOpts = [{return, list}, {parts, 2}, unicode],
S <- os:getenv()], Os = [list_to_tuple(re:split(S, "=", ReOpts)) || S <- os:getenv()],
%% Drop variables without a name (win32) %% Drop variables without a name (win32)
[T1 || {K, _V} = T1 <- Os, K =/= []]. [T1 || {K, _V} = T1 <- Os, K =/= []].