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:
Jan Klötzke 2011-09-29 22:18:03 +02:00 committed by Tuncer Ayaz
parent 36fe2c460c
commit b535b5eea8

View file

@ -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;
_ ->
lists:foldl(fun({Key, Value}, Acc) ->
"cmd /q /c " ++ lists:foldl(fun({Key, Value}, Acc) ->
expand_env_variable(Acc, Key, Value)
end, Cmd, Env)
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}}} ->