@@ -89,18 +89,25 @@ defmodule Mix.Shell do
89
89
end
90
90
91
91
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 ] )
93
93
94
- do_cmd ( port , callback )
94
+ do_cmd ( port , command , callback )
95
95
end
96
96
97
- defp do_cmd ( port , callback ) do
97
+ defp do_cmd ( port , command , callback ) do
98
98
receive do
99
99
{ ^ port , { :data , data } } ->
100
100
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
104
111
end
105
112
end
106
113
@@ -126,6 +133,8 @@ defmodule Mix.Shell do
126
133
127
134
defp validate_env ( enum ) do
128
135
Enum . map enum , fn
136
+ { k , nil } ->
137
+ { String . to_char_list ( k ) , false }
129
138
{ k , v } ->
130
139
{ String . to_char_list ( k ) , String . to_char_list ( v ) }
131
140
other ->
0 commit comments