aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFredrik Gustafsson <[email protected]>2013-07-09 14:40:40 +0200
committerFredrik Gustafsson <[email protected]>2013-07-09 14:40:40 +0200
commit37b97cc68e683366c47df6c30040c95176d60918 (patch)
tree44b0a0afe3f1d8bfdf89b877a564b36cfc786f04
parentbd990d7b877a4a564f0720ea0136ae6966612493 (diff)
parent55be33ed1fc4289c5f497a6bd03607ded97d6dd1 (diff)
downloadotp-37b97cc68e683366c47df6c30040c95176d60918.tar.gz
otp-37b97cc68e683366c47df6c30040c95176d60918.tar.bz2
otp-37b97cc68e683366c47df6c30040c95176d60918.zip
Merge branch 'maint'
-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, _} ->