Skip to content

Commit fca45d8

Browse files
author
José Valim
committed
Warn if no status after eof
1 parent a4ffd55 commit fca45d8

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

lib/mix/lib/mix/shell.ex

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,25 @@ defmodule Mix.Shell do
8989
end
9090

9191
port = Port.open({:spawn, shell_command(command)},
92-
[:stream, :binary, :exit_status, :hide, :use_stdio, {:env, env}|args])
92+
[:stream, :binary, :exit_status, :hide, :use_stdio, :eof, {:env, env}|args])
9393

94-
do_cmd(port, callback)
94+
do_cmd(port, command, callback)
9595
end
9696

97-
defp do_cmd(port, callback) do
97+
defp do_cmd(port, command, callback) do
9898
receive do
9999
{^port, {:data, data}} ->
100100
callback.(data)
101-
do_cmd(port, callback)
102-
{^port, {:exit_status, status}} ->
103-
status
101+
do_cmd(port, command, callback)
102+
{^port, :eof} ->
103+
receive do
104+
{^port, {:exit_status, status}} ->
105+
status
106+
after
107+
5_000 ->
108+
IO.puts :stderr, "warning: did not receive exit status after command: #{command}"
109+
0
110+
end
104111
end
105112
end
106113

@@ -126,6 +133,8 @@ defmodule Mix.Shell do
126133

127134
defp validate_env(enum) do
128135
Enum.map enum, fn
136+
{k, nil} ->
137+
{String.to_char_list(k), false}
129138
{k, v} ->
130139
{String.to_char_list(k), String.to_char_list(v)}
131140
other ->

0 commit comments

Comments
 (0)