mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 11:06:20 +00:00
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.
This commit is contained in:
parent
36fe2c460c
commit
b535b5eea8
1 changed files with 6 additions and 18 deletions
|
@ -109,22 +109,16 @@ sh(Command0, Options0) ->
|
||||||
ErrorHandler(Command, Err)
|
ErrorHandler(Command, Err)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% We use a bash shell to execute on windows if available. Otherwise we do the
|
%% We do the shell variable substitution ourselves on Windows and hope that the
|
||||||
%% shell variable substitution ourselves and hope that the command doesn't use
|
%% command doesn't use any other shell magic.
|
||||||
%% any shell magic. Also the port doesn't seem to close from time to time
|
|
||||||
%% (mingw).
|
|
||||||
patch_on_windows(Cmd, Env) ->
|
patch_on_windows(Cmd, Env) ->
|
||||||
case os:type() of
|
case os:type() of
|
||||||
{win32,nt} ->
|
{win32,nt} ->
|
||||||
case find_executable("bash") of
|
"cmd /q /c " ++ lists:foldl(fun({Key, Value}, Acc) ->
|
||||||
false -> Cmd;
|
expand_env_variable(Acc, Key, Value)
|
||||||
Bash ->
|
end, Cmd, Env);
|
||||||
Bash ++ " -c \"" ++ Cmd ++ "; echo _port_cmd_status_ $?\" "
|
|
||||||
end;
|
|
||||||
_ ->
|
_ ->
|
||||||
lists:foldl(fun({Key, Value}, Acc) ->
|
Cmd
|
||||||
expand_env_variable(Acc, Key, Value)
|
|
||||||
end, Cmd, Env)
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
find_files(Dir, Regex) ->
|
find_files(Dir, Regex) ->
|
||||||
|
@ -245,12 +239,6 @@ log_and_abort(Command, {Rc, Output}) ->
|
||||||
|
|
||||||
sh_loop(Port, Fun, Acc) ->
|
sh_loop(Port, Fun, Acc) ->
|
||||||
receive
|
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}}} ->
|
{Port, {data, {eol, Line}}} ->
|
||||||
sh_loop(Port, Fun, Fun(Line ++ "\n", Acc));
|
sh_loop(Port, Fun, Fun(Line ++ "\n", Acc));
|
||||||
{Port, {data, {noeol, Line}}} ->
|
{Port, {data, {noeol, Line}}} ->
|
||||||
|
|
Loading…
Reference in a new issue