-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshell_cmds.erl
64 lines (58 loc) · 1.77 KB
/
shell_cmds.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
-module(shell_cmds).
%%% Common shell pitfalls
%%
%% Using bound variables
%% > X = 1.
%% ...
%% > X = 2. % no matching right hand side value
%% > f(X). % or f().
%% > X = 2. % now ok
%%
%% Creating fun with receive clause
%% > spawn(fun() -> receive X -> X end). IS INCORRECT
%% > spawn(fun() -> receive X -> X end end). IS OK
%%
%% Trying to use records
%% > -record(person, {name,age}). % undefined shell command record
%% > rd(person, {name, age}). % this is ok
%%
%% Getting stuck in shell
%% > receive X -> X end. % after this command the shell is block
%% type ^G
%% --> s
%% --> j
%% you get list of all jobs
%% --> c N % N - id of new shell job (i.e. 2)
%% if you want to kill previous shell
%% type ^G
%% --> j
%% --> k N % N - id of the job you want to kill
%%
%% Easier way:
%% type ^G
%% --> i
%% --> c
%%
%% This (both ways) kills the shell (it is obviously restarted).
%% You lose your ETS tables + all linked processes are killed
%% If you can't affort loosing these you can switch (^G s c)
%% to another shell and repair the situation (i.e. send a message
%% to process stuck in receive expression).
%%% Most common shell cmds
%% f() - forget all bindings (very common)
%% c(Module) - compile and load module
%% q() - quit
%%% ^G commands (type ctrl+g to run 'user switch commnad')
%% h - print all available commands
%%% Other very common shell cmds
%% help() -- print all available cmds
%% f(X) - forget X variable binding
%% v(N) - use value of query N
%% rd, rf, rl, rp, rr - record related cmds
%% bt(Pid) - backtrace (obvious)
%% flush() -> print all messages to the shell process
%% i() - print info about running processes
%% i(X,Y,Z) - print info about pid <<X.Y.Z>>
%% regs() - information about registered processes
%%% Cmds similar to linux cmds
%% cd, pwd, ls