Skip to content

Commit

Permalink
Merge pull request #2818 from oubiwann/2817/erlang26-custom-shell-fix
Browse files Browse the repository at this point in the history
Erlang 26 custom shell fix
  • Loading branch information
ferd committed Aug 10, 2023
2 parents 9ae99e9 + 72250dd commit 3f82933
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions apps/rebar/src/rebar_prv_shell.erl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
-define(DEPS, [compile]).

-dialyzer({nowarn_function, rewrite_leaders/2}).
-dialyzer({nowarn_function, start_interactive/0}).
-dialyzer({nowarn_function, start_interactive/1}).

%% ===================================================================
%% Public API
Expand Down Expand Up @@ -82,19 +82,23 @@ init(State) ->
"relx apps if not specified."},
{relname, $r, "relname", atom,
"Name of the release to use as a template for the "
"shell session"},
"shell session."},
{relvsn, $v, "relvsn", string,
"Version of the release to use for the shell "
"session"},
"session."},
{start_clean, undefined, "start-clean", boolean,
"Cancel any applications in the 'apps' list "
"or release."},
{env_file, undefined, "env-file", string,
"Path to file of os environment variables to setup "
"before expanding vars in config files."},
{user_drv_args, undefined, "user_drv_args", string,
"Arguments passed to user_drv start function for "
"creating custom shells."},
"For versions of Erlang prior to 26, this option "
"can be used to pass arguments to the user_drv start "
"function for creating custom shells. Starting "
"with Erlang 26, the arguments defined with this "
"option are applied to the shell start_interactive "
"function."},
{eval, undefined, "eval", string,
"Erlang term(s) to execute after the apps have been "
"started, but before the shell is presented to the "
Expand Down Expand Up @@ -130,7 +134,7 @@ shell(State) ->
setup_name(State),
setup_paths(State),
ShellArgs = debug_get_value(shell_args, rebar_state:get(State, shell, []), undefined,
"Found user_drv args from command line option."),
"Found shell args from command line option or plugin."),
setup_shell(ShellArgs),
maybe_run_script(State),
%% apps must be started after the change in shell because otherwise
Expand Down Expand Up @@ -168,11 +172,11 @@ setup_shell(ShellArgs) ->
rewrite_leaders(OldUser, NewUser),
maybe_reset_logger(LoggerState);
true ->
ok = start_interactive()
ok = start_interactive(ShellArgs)
end.

start_interactive() ->
shell:start_interactive().
start_interactive(ShellArgs) ->
apply(shell, start_interactive, ShellArgs).

%% @private starting with OTP-21.2.3, there's an oddity where the logger
%% likely tries to handle system logs while we take down the TTY, which
Expand Down

0 comments on commit 3f82933

Please sign in to comment.