Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
  • Loading branch information
garazdawi committed Feb 29, 2024
2 parents 157d062 + b6c6537 commit bdffc10
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lib/kernel/src/group.erl
Original file line number Diff line number Diff line change
Expand Up @@ -471,13 +471,21 @@ getopts(Drv,Buf) ->
%% {error,What,NewSaveBuffer}

get_password_chars(Drv,Shell,Buf) ->
case get_password_line(Buf, Drv, Shell) of
{done, Line, Buf1} ->
{ok, Line, Buf1};
interrupted ->
{error, {error, interrupted}, []};
terminated ->
{exit, terminated}
case get(echo) of
true ->
case get_password_line(Buf, Drv, Shell) of
{done, Line, Buf1} ->
{ok, Line, Buf1};
interrupted ->
{error, {error, interrupted}, []};
terminated ->
{exit, terminated}
end;
false ->
%% Echo needs to be set to true, otherwise the
%% password will be printed to the shell and we
%% do not want that.
{error, {error, enotsup}, []}
end.

get_chars_n(Prompt, M, F, Xa, Drv, Shell, Buf, Encoding) ->
Expand Down Expand Up @@ -1107,7 +1115,7 @@ get_password_line(Chars, Drv, Shell) ->
get_password1({Chars,[]}, Drv, Shell) ->
receive
{Drv,{data,Cs}} ->
get_password1(edit_password(Cs,cast(Chars,list)),Drv,Shell);
get_password1(edit_password(cast(Cs,list),Chars),Drv,Shell);
{io_request,From,ReplyAs,Req} when is_pid(From) ->
io_request(Req, From, ReplyAs, Drv, Shell, []), %WRONG!!!
%% I guess the reason the above line is wrong is that Buf is
Expand Down
16 changes: 16 additions & 0 deletions lib/kernel/test/interactive_shell_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
shell_history_custom/1, shell_history_custom_errors/1,
job_control_remote_noshell/1,ctrl_keys/1,
get_columns_and_rows_escript/1,
shell_get_password/1,
shell_navigation/1, shell_multiline_navigation/1, shell_multiline_prompt/1,
shell_xnfix/1, shell_delete/1,
shell_transpose/1, shell_search/1, shell_insert/1,
Expand Down Expand Up @@ -86,6 +87,7 @@ groups() ->
job_control_remote, job_control_remote_noshell,
ctrl_keys, stop_during_init, wrap,
shell_invalid_ansi,
shell_get_password,
{group, shell_history},
{group, remsh}]},
{shell_history, [],
Expand Down Expand Up @@ -1329,6 +1331,20 @@ shell_invalid_ansi(_Config) ->
"-eval","shell:prompt_func({interactive_shell_SUITE,prompt})."
]).

shell_get_password(_Config) ->

rtnode:run(
[{putline,"io:get_password()."},
{putline,"secret\r"},
{expect, "\r\n\r\n\"secret\""}]),

%% io:get_password only works when run in "newshell"
rtnode:run(
[{putline,"io:get_password()."},
{expect, "\\Q{error,enotsup}\\E"}],
"","",["-oldshell"]).


shell_ignore_pager_commands(Config) ->
Term = start_tty(Config),
case code:get_doc(file, #{sources=>[eep48]}) of
Expand Down

0 comments on commit bdffc10

Please sign in to comment.