Skip to content

Commit

Permalink
Support environment vars with unicode characters
Browse files Browse the repository at this point in the history
The results returned by os:getenv() may contain unicode characters.
That said, we need to explicitly allow unicode when splitting the
environment information, otherwise badarg will be raised causing all
rebar commands to fail until the environment variable is removed.
  • Loading branch information
José Valim authored and l4u committed Nov 21, 2012
1 parent 7dad2b3 commit 61c353d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rebar_port_compiler.erl
Expand Up @@ -399,7 +399,7 @@ expand_vars_loop([], Recurse, Vars, Count) ->
expand_vars_loop(Recurse, [], Vars, Count-1);
expand_vars_loop([{K, V} | Rest], Recurse, Vars, Count) ->
%% 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
{match, Matches} ->
%% Identify the unique variables that need to be expanded
Expand Down Expand Up @@ -472,8 +472,8 @@ erts_dir() ->
lists:concat([code:root_dir(), "/erts-", erlang:system_info(version)]).

os_env() ->
Os = [list_to_tuple(re:split(S, "=", [{return, list}, {parts, 2}])) ||
S <- os:getenv()],
ReOpts = [{return, list}, {parts, 2}, unicode],
Os = [list_to_tuple(re:split(S, "=", ReOpts)) || S <- os:getenv()],
%% Drop variables without a name (win32)
[T1 || {K, _V} = T1 <- Os, K =/= []].

Expand Down

0 comments on commit 61c353d

Please sign in to comment.