Skip to content

Commit e301074

Browse files
authored
Merge pull request #2 from lpil/recur
Error if the boot module is instructed to run itself
2 parents c74e5f8 + fcc49ba commit e301074

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

runtime.erl

+10-5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ main() ->
66
Mod = get_main_module(),
77
erlang:display({"Starting", Mod}),
88
% erlang:display(code:all_loaded()),
9-
erlang:display(length(processes())),
10-
% length(registered()).)
9+
% erlang:display(length(processes())),
10+
% length(registered())).
1111
R = Mod:main(),
1212
erlang:display({"Done", R}),
1313
erlang:halt().
@@ -16,14 +16,19 @@ module_name(Str) ->
1616
case catch list_to_atom(Str) of
1717
{'EXIT', _} ->
1818
erlang:display("Bad module name: " ++ Str),
19-
erlang:halt();
19+
erlang:halt(1);
20+
21+
?MODULE ->
22+
erlang:display("Attempting to run boot module. Try another module"),
23+
erlang:halt(1);
24+
2025
Mod -> Mod
2126
end.
2227

2328
get_main_module() ->
2429
case init:get_argument(load) of
2530
{ok, [[Arg]]} -> module_name(Arg);
2631
_ ->
27-
erlang:display("Missing: -load Mod"),
28-
erlang:halt()
32+
erlang:display("Missing command line argument: -load Mod"),
33+
erlang:halt(1)
2934
end.

0 commit comments

Comments
 (0)