diff options
author | Fredrik Gustafsson <[email protected]> | 2013-07-09 14:40:31 +0200 |
---|---|---|
committer | Fredrik Gustafsson <[email protected]> | 2013-07-09 14:40:31 +0200 |
commit | 55be33ed1fc4289c5f497a6bd03607ded97d6dd1 (patch) | |
tree | 2a8468ff542d35034557721bf979683e2ade0a7e /lib | |
parent | 5c6ffdaab0ca5792a22a74f4e900b47a5bdd8cd7 (diff) | |
parent | 59053f84228b27ecf28f2de31b4a45074b2d04c9 (diff) | |
download | otp-55be33ed1fc4289c5f497a6bd03607ded97d6dd1.tar.gz otp-55be33ed1fc4289c5f497a6bd03607ded97d6dd1.tar.bz2 otp-55be33ed1fc4289c5f497a6bd03607ded97d6dd1.zip |
Merge branch 'sze/ssh_cli_handles/OTP-11199' into maint
* sze/ssh_cli_handles/OTP-11199:
Make ssh_cli.erl handle <CTRL>+C
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ssh/src/ssh_cli.erl | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/ssh/src/ssh_cli.erl b/lib/ssh/src/ssh_cli.erl index 69b1ab186f..54911e757c 100644 --- a/lib/ssh/src/ssh_cli.erl +++ b/lib/ssh/src/ssh_cli.erl @@ -68,7 +68,8 @@ init([Shell]) -> handle_ssh_msg({ssh_cm, _ConnectionManager, {data, _ChannelId, _Type, Data}}, #state{group = Group} = State) -> - Group ! {self(), {data, binary_to_list(Data)}}, + List = binary_to_list(Data), + to_group(List, Group), {ok, State}; handle_ssh_msg({ssh_cm, ConnectionManager, @@ -188,6 +189,22 @@ terminate(_Reason, _State) -> %%% Internal functions %%-------------------------------------------------------------------- +to_group([], _Group) -> + ok; +to_group([$\^C | Tail], Group) -> + exit(Group, interrupt), + to_group(Tail, Group); +to_group(Data, Group) -> + Func = fun(C) -> C /= $\^C end, + Tail = case lists:splitwith(Func, Data) of + {[], Right} -> + Right; + {Left, Right} -> + Group ! {self(), {data, Left}}, + Right + end, + to_group(Tail, Group). + exec(Cmd) -> case eval(parse(scan(Cmd))) of {error, _} -> |