diff options
author | Fredrik Gustafsson <[email protected]> | 2013-07-09 14:45:13 +0200 |
---|---|---|
committer | Fredrik Gustafsson <[email protected]> | 2013-07-09 14:45:13 +0200 |
commit | 2db8fc3414015bf556d58d4a1d4a4493fc746a00 (patch) | |
tree | 48f6f7407d8b3dbf3423b91b7ae67e0383d613c5 /lib/ssh | |
parent | 2762ff6ffadbc9100d3dc79ffdbdfb3286e0ba25 (diff) | |
parent | 59053f84228b27ecf28f2de31b4a45074b2d04c9 (diff) | |
download | otp-2db8fc3414015bf556d58d4a1d4a4493fc746a00.tar.gz otp-2db8fc3414015bf556d58d4a1d4a4493fc746a00.tar.bz2 otp-2db8fc3414015bf556d58d4a1d4a4493fc746a00.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/ssh')
-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, _} -> |