aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh
diff options
context:
space:
mode:
authorFredrik Gustafsson <[email protected]>2013-07-09 14:40:31 +0200
committerFredrik Gustafsson <[email protected]>2013-07-09 14:40:31 +0200
commit55be33ed1fc4289c5f497a6bd03607ded97d6dd1 (patch)
tree2a8468ff542d35034557721bf979683e2ade0a7e /lib/ssh
parent5c6ffdaab0ca5792a22a74f4e900b47a5bdd8cd7 (diff)
parent59053f84228b27ecf28f2de31b4a45074b2d04c9 (diff)
downloadotp-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/ssh')
-rw-r--r--lib/ssh/src/ssh_cli.erl19
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, _} ->