From b535b5eea82f5d73191915e790b0702e143c1957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kl=C3=B6tzke?= Date: Thu, 29 Sep 2011 22:18:03 +0200 Subject: 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. --- src/rebar_utils.erl | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index 4148160..84567ba 100644 --- a/src/rebar_utils.erl +++ b/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}}} -> -- cgit v1.1