summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Klötzke <jan.kloetzke@freenet.de>2011-09-29 22:18:03 +0200
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2011-10-20 16:27:35 +0200
commitb535b5eea82f5d73191915e790b0702e143c1957 (patch)
tree9a092a998186a8ba9093aef57ea9d68d8076a782 /src
parent36fe2c460c5ec35859b0bbd6c54b708850bb18a1 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/rebar_utils.erl24
1 files changed, 6 insertions, 18 deletions
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}}} ->