Skip to content

Commit 3137bfc

Browse files
author
José Valim
committed
Move bootstrap code for IEx to IEx.CLI
1 parent 4d3d61e commit 3137bfc

File tree

5 files changed

+6
-31
lines changed

5 files changed

+6
-31
lines changed

bin/elixir

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ SELF=$(readlink_f "$0")
6969
SCRIPT_PATH=$(dirname "$SELF")
7070

7171
if [ -f "$HOME/.elixirrc" ]; then . "$HOME/.elixirrc"; fi
72+
if [ "$ELIXIR_NO_CLI" != "1" ]; then ERL="$ERL -s elixir start_cli"; fi
7273

7374
if [ -f "$SCRIPT_PATH/../releases/RELEASES" ] && [ -f "$SCRIPT_PATH/erl" ]
7475
then
75-
exec "$SCRIPT_PATH"/erl -env ERL_LIBS $ERL_LIBS:"$SCRIPT_PATH/../lib" -boot elixir -noshell $ELIXIR_ERL_OPTS $ERL -s elixir start_cli -extra "$@"
76+
exec "$SCRIPT_PATH"/erl -env ERL_LIBS $ERL_LIBS:"$SCRIPT_PATH/../lib" -boot elixir -noshell $ELIXIR_ERL_OPTS $ERL -extra "$@"
7677
else
77-
exec erl -env ERL_LIBS $ERL_LIBS:"$SCRIPT_PATH/../lib" -noshell $ELIXIR_ERL_OPTS $ERL -s elixir start_cli -extra "$@"
78+
exec erl -env ERL_LIBS $ERL_LIBS:"$SCRIPT_PATH/../lib" -noshell $ELIXIR_ERL_OPTS $ERL -extra "$@"
7879
fi

bin/iex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ readlink_f () {
1111

1212
SELF=$(readlink_f "$0")
1313
SCRIPT_PATH=$(dirname "$SELF")
14-
exec "$SCRIPT_PATH"/elixir --no-halt --erl "-user Elixir-IEx-CLI" "$@"
14+
ELIXIR_NO_CLI=1 exec "$SCRIPT_PATH"/elixir --no-halt --erl "-user Elixir-IEx-CLI" "$@"

lib/elixir/lib/kernel/cli.ex

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,9 @@ defmodule Kernel.CLI do
1616

1717
run fn ->
1818
Enum.map Enum.reverse(config.commands), process_command(&1, config)
19-
:elixir_code_server.cast(:finished)
2019
end, config.halt
2120
end
2221

23-
@doc """
24-
Wait until the CLI finishes processing options.
25-
"""
26-
def wait_until_finished do
27-
case :elixir_code_server.call({ :wait_until_finished, self }) do
28-
:wait ->
29-
receive do
30-
{ :elixir_code_server, :finished } -> :ok
31-
end
32-
:ok -> :ok
33-
end
34-
end
35-
3622
@doc """
3723
Runs the given function by catching any failure
3824
and printing them to stdout. `at_exit` hooks are

lib/elixir/src/elixir_code_server.erl

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ start_link() ->
3030
init(_args) ->
3131
{ ok, #elixir_code_server{} }.
3232

33-
handle_call({ wait_until_finished, Pid }, _, Config) ->
34-
Waiting = Config#elixir_code_server.waiting,
35-
case is_list(Waiting) of
36-
true -> { reply, wait, Config#elixir_code_server{waiting=[Pid|Waiting]} };
37-
false -> { reply, ok, Config }
38-
end;
39-
4033
handle_call({ acquire, Path }, From, Config) ->
4134
Current = Config#elixir_code_server.loaded,
4235
case orddict:find(Path, Current) of
@@ -87,11 +80,6 @@ handle_cast({ compiler_options, Options }, Config) ->
8780
Final = orddict:merge(fun(_,_,V) -> V end, Config#elixir_code_server.compiler_options, Options),
8881
{ noreply, Config#elixir_code_server{compiler_options=Final} };
8982

90-
handle_cast(finished, Config) ->
91-
Waiting = Config#elixir_code_server.waiting,
92-
[Pid ! { elixir_code_server, finished } || Pid <- lists:reverse(Waiting)],
93-
{ noreply, Config#elixir_code_server{waiting=done} };
94-
9583
handle_cast({ loaded, Path }, Config) ->
9684
Current = Config#elixir_code_server.loaded,
9785
case orddict:find(Path, Current) of

lib/iex/lib/iex/cli.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defmodule IEx.CLI do
1111
else
1212
:user.start
1313
IO.puts "Warning: could not run smart terminal, falling back to dumb one"
14-
IEx.start
14+
IEx.start([], fn -> :elixir.start_cli end)
1515
end
1616
end
1717

@@ -30,7 +30,7 @@ defmodule IEx.CLI do
3030

3131
defp tty do
3232
function = fn ->
33-
IEx.start([], fn -> Kernel.CLI.wait_until_finished end)
33+
IEx.start([], fn -> :elixir.start_cli end)
3434
end
3535

3636
args =

0 commit comments

Comments
 (0)