Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/util/args.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ defmodule Burrito.Util.Args do
"""
@spec get_arguments :: list(String.t())
def get_arguments do
:init.get_plain_arguments() |> Enum.map(&to_string/1)
:init.get_plain_arguments()
|> Enum.map(&to_string/1)
|> strip_separator()
end

# The wrapper passes `--no-halt --` after `-extra` to keep Elixir's CLI from
# halting the VM and from claiming the application's arguments. Neither is an
# argument, so drop them. Only this exact leading pair is matched, so an
# application that takes its own `--` still sees it.
defp strip_separator(["--no-halt", "--" | rest]), do: rest
defp strip_separator(["--" | rest]), do: rest
defp strip_separator(args), do: args

@doc """
Get the arguments from the CLI, regardless if run under Burrito or not.
"""
Expand Down
13 changes: 13 additions & 0 deletions src/erlang_launcher.zig
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ pub fn launch(io: Io, install_dir: []const u8, env_map: *std.process.Environ.Map
"-config",
config_sys_path,
"-extra",
// These two are for Elixir's CLI, which runs via `-s elixir start_cli`
// above and reads everything after `-extra`.
//
// --no-halt: without it the CLI halts the VM once it finishes, killing
// any application that is meant to keep running.
//
// --: without it the CLI claims --version and --help for itself and
// treats the first remaining argument as a script path.
//
// Burrito.Util.Args strips both back off before the application sees
// its arguments.
"--no-halt",
"--",
};

// Cross-platform: build args once, set env, spawn child, wait for exit
Expand Down
Loading