Просмотр исходного кода

rebar_utils:sh/2: remove bash invocation on Windows

Currently rebar_utils:sh/2 will invoke all commands through bash.exe if
found. Otherwise the command will be executed directly. Despite the fact
that the caller cannot know if the command is executed with Unix or
Windows semantics it leads to problems with MSYS's automatic path name
translation.

Therefore remove bash usage on Windows to get a consistent behavior and
to avoid the peculiarities of MSYS's automatic path conversion. Instead
use cmd.exe as its typically needed by most commands.
pull/3/head
Jan Klötzke 13 лет назад
committed by Tuncer Ayaz
Родитель
Сommit
b535b5eea8
1 измененных файлов: 6 добавлений и 18 удалений
  1. +6
    -18
      src/rebar_utils.erl

+ 6
- 18
src/rebar_utils.erl Просмотреть файл

@ -109,22 +109,16 @@ sh(Command0, Options0) ->
ErrorHandler(Command, Err)
end.
%% We use a bash shell to execute on windows if available. Otherwise we do the
%% shell variable substitution ourselves and hope that the command doesn't use
%% any shell magic. Also the port doesn't seem to close from time to time
%% (mingw).
%% We do the shell variable substitution ourselves on Windows and hope that the
%% command doesn't use any other shell magic.
patch_on_windows(Cmd, Env) ->
case os:type() of
{win32,nt} ->
case find_executable("bash") of
false -> Cmd;
Bash ->
Bash ++ " -c \"" ++ Cmd ++ "; echo _port_cmd_status_ $?\" "
end;
"cmd /q /c " ++ lists:foldl(fun({Key, Value}, Acc) ->
expand_env_variable(Acc, Key, Value)
end, Cmd, Env);
_ ->
lists:foldl(fun({Key, Value}, Acc) ->
expand_env_variable(Acc, Key, Value)
end, Cmd, Env)
Cmd
end.
find_files(Dir, Regex) ->
@ -245,12 +239,6 @@ log_and_abort(Command, {Rc, Output}) ->
sh_loop(Port, Fun, Acc) ->
receive
{Port, {data, {_, "_port_cmd_status_ " ++ Status}}} ->
(catch erlang:port_close(Port)), % sigh () for indentation
case list_to_integer(Status) of
0 -> {ok, lists:flatten(Acc)};
Rc -> {error, Rc}
end;
{Port, {data, {eol, Line}}} ->
sh_loop(Port, Fun, Fun(Line ++ "\n", Acc));
{Port, {data, {noeol, Line}}} ->

Загрузка…
Отмена
Сохранить