60 lines
1.2 KiB
Text
60 lines
1.2 KiB
Text
-module(ssh_cli).
|
|
|
|
-behaviour(ssh_channel).
|
|
|
|
-include("ssh.hrl").
|
|
%% backwards compatibility
|
|
-export([listen/1, listen/2, listen/3, listen/4, stop/1]).
|
|
|
|
if L =/= [] -> % If L is not empty
|
|
sum(L) / count(L);
|
|
true ->
|
|
error
|
|
end.
|
|
|
|
%% state
|
|
-record(state, {
|
|
cm,
|
|
channel
|
|
}).
|
|
|
|
-spec foo(integer()) -> integer().
|
|
foo(X) -> 1 + X.
|
|
|
|
test(Foo)->Foo.
|
|
|
|
init([Shell, Exec]) ->
|
|
{ok, #state{shell = Shell, exec = Exec}};
|
|
init([Shell]) ->
|
|
false = not true,
|
|
io:format("Hello, \"~p!~n", [atom_to_list('World')]),
|
|
{ok, #state{shell = Shell}}.
|
|
|
|
concat([Single]) -> Single;
|
|
concat(RList) ->
|
|
EpsilonFree = lists:filter(
|
|
fun (Element) ->
|
|
case Element of
|
|
epsilon -> false;
|
|
_ -> true
|
|
end
|
|
end,
|
|
RList),
|
|
case EpsilonFree of
|
|
[Single] -> Single;
|
|
Other -> {concat, Other}
|
|
end.
|
|
|
|
union_dot_union({union, _}=U1, {union, _}=U2) ->
|
|
union(lists:flatten(
|
|
lists:map(
|
|
fun (X1) ->
|
|
lists:map(
|
|
fun (X2) ->
|
|
concat([X1, X2])
|
|
end,
|
|
union_to_list(U2)
|
|
)
|
|
end,
|
|
union_to_list(U1)
|
|
))).
|