Skip to content

Commit 49ae019

Browse files
committed
New shell functions pi/1 and pi/3 instead of i/3
Since the shell accepts the `<X.Y.Z>` syntax for pids, it was surprising that `i(X,Y,Z)` worked, but `i(<X.Y.Z>)` did not, so you could not simply paste a pid. The name `i/1` was however in use by an undocumented function, and furthermore, the `i/0` info function produces a very different output from `i/3`, so we instead introduce the new names `pi/1` and `pi/3`, deprecating `i/3`. Example: 1> pi(<0.90.0>). [{current_function,{c,pinfo,1}}, {initial_call,{erlang,apply,2}}, {status,running}, ...
1 parent 81c2d16 commit 49ae019

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

lib/stdlib/src/c.erl

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ commands.
4747
-export([help/0,lc/1,c/1,c/2,c/3,nc/1,nc/2, nl/1,l/1,i/0,i/1,ni/0,
4848
y/1, y/2,
4949
lc_batch/0, lc_batch/1,
50-
i/3,pid/3,m/0,m/1,mm/0,lm/0,
50+
pi/1,pi/3,i/3,pid/3,m/0,m/1,mm/0,lm/0,
5151
bt/1, q/0,
5252
h/1,h/2,h/3,h1/1,h1/2,h1/3,ht/1,ht/2,ht/3,hcb/1,hcb/2,hcb/3,
5353
erlangrc/0,erlangrc/1,bi/1, flush/0, regs/0, uptime/0,
@@ -84,7 +84,7 @@ help() ->
8484
"ht(Mod,Type,Arity) -- help about type with arity in module\n"
8585
"help() -- help info\n"
8686
"i() -- information about the system\n"
87-
"i(X,Y,Z) -- information about pid <X,Y,Z>\n"
87+
"i(X,Y,Z) -- deprecated alias for pi(X,Y,Z)\n"
8888
"l(Module) -- load or reload module\n"
8989
"lc([File]) -- compile a list of Erlang modules\n"
9090
"lm() -- load all modified modules\n"
@@ -99,6 +99,8 @@ help() ->
9999
"ni() -- information about the networked system\n"
100100
"nl(Module) -- load module on all nodes\n"
101101
"nregs() -- information about all registered processes\n"
102+
"pi(Pid) -- information about process <Pid>\n"
103+
"pi(X,Y,Z) -- information about pid <X,Y,Z>\n"
102104
"pid(X,Y,Z) -- convert X,Y,Z to a Pid\n"
103105
"pwd() -- print working directory\n"
104106
"q() -- quit - shorthand for init:stop()\n"
@@ -954,15 +956,34 @@ pid(X, Y, Z) ->
954956
integer_to_list(Z) ++ ">").
955957

956958
-doc """
957-
Displays information about a process, Equivalent to
958-
[`process_info(pid(X, Y, Z))`](`process_info/1`), but location transparent.
959+
Old alias for `pi(X, Y, Z)`. Note that the output of `i(X, Y, Z)` is
960+
very different from that of `i()`, so the new name is preferred.
959961
""".
960962
-spec i(X, Y, Z) -> [{atom(), term()}] when
961963
X :: non_neg_integer(),
962964
Y :: non_neg_integer(),
963965
Z :: non_neg_integer().
964966

965-
i(X, Y, Z) -> pinfo(pid(X, Y, Z)).
967+
i(X, Y, Z) -> pi(X, Y, Z).
968+
969+
-doc """
970+
Equivalent to `pi(pid(X, Y, Z))`.
971+
""".
972+
-spec pi(X, Y, Z) -> [{atom(), term()}] when
973+
X :: non_neg_integer(),
974+
Y :: non_neg_integer(),
975+
Z :: non_neg_integer().
976+
977+
pi(X, Y, Z) -> pi(pid(X, Y, Z)).
978+
979+
-doc """
980+
Displays information about a process, Equivalent to
981+
[`process_info(Pid)`](`process_info/1`), but location transparent.
982+
""".
983+
-spec pi(Pid) -> [{atom(), term()}] when
984+
Pid :: pid().
985+
986+
pi(Pid) -> pinfo(Pid).
966987

967988
-doc """
968989
This function is shorthand for `init:stop()`, that is, it causes the node to

lib/stdlib/src/shell.erl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,7 @@ write_and_compile_module(PathToFile, Output) ->
15841584
ok -> c:c(PathToFile);
15851585
Error -> Error
15861586
end.
1587+
15871588
non_builtin_local_func(F,As,Bs, FT) ->
15881589
Arity = length(As),
15891590
case erlang:function_exported(user_default, F, Arity) of

lib/stdlib/src/shell_default.erl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ code:load_abs("$PATH/user_default").
5959
`$PATH` is the directory where your `user_default` module can be found.
6060
""".
6161

62-
-export([help/0,lc/1,c/1,c/2,c/3,nc/1,nl/1,l/1,i/0,pid/3,i/3,m/0,m/1,lm/0,mm/0,
62+
-export([help/0,lc/1,c/1,c/2,c/3,nc/1,nl/1,l/1,i/0,pid/3,i/3,pi/1,pi/3,m/0,m/1,lm/0,mm/0,
6363
memory/0,memory/1,uptime/0,
6464
erlangrc/1,bi/1, regs/0, flush/0,pwd/0,ls/0,ls/1,cd/1,
6565
y/1, y/2,
@@ -127,6 +127,10 @@ i() -> c:i().
127127
-doc false.
128128
i(X,Y,Z) -> c:i(X,Y,Z).
129129
-doc false.
130+
pi(X,Y,Z) -> c:pi(X,Y,Z).
131+
-doc false.
132+
pi(Pid) -> c:pi(Pid).
133+
-doc false.
130134
l(Mod) -> c:l(Mod).
131135
-doc false.
132136
lc(X) -> c:lc(X).

0 commit comments

Comments
 (0)