diff options
author | Niclas Eklund <[email protected]> | 2010-12-10 17:00:02 +0100 |
---|---|---|
committer | Niclas Eklund <[email protected]> | 2010-12-10 17:00:02 +0100 |
commit | 8bd0325c850ad70e514f680a2dd7020144773665 (patch) | |
tree | 9d8ad2b52391cb54db7fef5c84d0b519c1d48c34 /lib/ssh/src/ssh_cli.erl | |
parent | 3cf40cefd44ab6383bd16319c7c6941fd0d0f13c (diff) | |
parent | caa311d4a2b5fb229d9369c7667b062b34945b36 (diff) | |
download | otp-8bd0325c850ad70e514f680a2dd7020144773665.tar.gz otp-8bd0325c850ad70e514f680a2dd7020144773665.tar.bz2 otp-8bd0325c850ad70e514f680a2dd7020144773665.zip |
Merge branch 'maint-r13' of super:otp into nick/orber/recursive_types/OTP-8868
Diffstat (limited to 'lib/ssh/src/ssh_cli.erl')
-rw-r--r-- | lib/ssh/src/ssh_cli.erl | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/ssh/src/ssh_cli.erl b/lib/ssh/src/ssh_cli.erl index 2764ea2e43..57ba87bd42 100644 --- a/lib/ssh/src/ssh_cli.erl +++ b/lib/ssh/src/ssh_cli.erl @@ -419,14 +419,12 @@ start_shell(ConnectionManager, State) -> Shell = State#state.shell, ShellFun = case is_function(Shell) of true -> + {ok, User} = + ssh_userreg:lookup_user(ConnectionManager), case erlang:fun_info(Shell, arity) of {arity, 1} -> - {ok, User} = - ssh_userreg:lookup_user(ConnectionManager), fun() -> Shell(User) end; {arity, 2} -> - {ok, User} = - ssh_userreg:lookup_user(ConnectionManager), {ok, PeerAddr} = ssh_connection_manager:peer_addr(ConnectionManager), fun() -> Shell(User, PeerAddr) end; @@ -441,10 +439,28 @@ start_shell(ConnectionManager, State) -> State#state{group = Group, buf = empty_buf()}. start_shell(_ConnectionManager, Cmd, #state{exec={M, F, A}} = State) -> - Group = group:start(self(), {M, F, A++[Cmd]}, [{echo,false}]), + Group = group:start(self(), {M, F, A++[Cmd]}, [{echo, false}]), + State#state{group = Group, buf = empty_buf()}; +start_shell(ConnectionManager, Cmd, #state{exec=Shell} = State) when is_function(Shell) -> + {ok, User} = + ssh_userreg:lookup_user(ConnectionManager), + ShellFun = + case erlang:fun_info(Shell, arity) of + {arity, 1} -> + fun() -> Shell(Cmd) end; + {arity, 2} -> + fun() -> Shell(Cmd, User) end; + {arity, 3} -> + {ok, PeerAddr} = + ssh_connection_manager:peer_addr(ConnectionManager), + fun() -> Shell(Cmd, User, PeerAddr) end; + _ -> + Shell + end, + Echo = get_echo(State#state.pty), + Group = group:start(self(), ShellFun, [{echo,Echo}]), State#state{group = Group, buf = empty_buf()}. - % Pty can be undefined if the client never sets any pty options before % starting the shell. get_echo(undefined) -> |