檢視原始碼 c (stdlib v6.2)

命令列介面模組。

這個模組讓使用者可以輸入一些常用命令的簡短形式。

注意

這些函式僅供在 Erlang Shell 中互動使用。模組前綴可以省略。

另請參閱

filenamecompileerlangyeccxref

摘要

函式

顯示行程的堆疊回溯。等同於 erlang:process_display(Pid, backtrace)

作用類似於 c(Module, [])

編譯,然後清除並載入模組的程式碼。Module 可以是模組名稱或原始碼檔案路徑,可以帶或不帶 .erl 副檔名。

編譯,然後清除並載入模組 Module 的程式碼,Module 必須是一個原子。

將工作目錄變更為 Dir,可以是相對名稱,然後印出新的工作目錄名稱。

搜尋 PathList 並載入找到的 .erlang 資源檔。

清除所有傳送到 shell 的訊息。

印出 Module 的文件。

印出所有 Module:Function 的文件(不論 arity)。

印出 Module:Function/Arity 的文件。

印出 Module 的回呼文件。

印出所有 Module:Callback 的回呼文件(不論 arity)。

印出 Module:Callback/Arity 的回呼文件。

顯示說明資訊:所有有效的 shell 內部命令和此模組中的命令。

印出 Module 的類型文件。

印出 ModuleType 的類型文件,不論 arity。

印出 ModuleType/Arity 的類型文件。

i()

等同於 ni/0

顯示行程的資訊,等同於 process_info(pid(X, Y, Z)),但位置透明。

藉由呼叫 code:purge(Module),然後呼叫 code:load_file(Module) 來清除並載入或重新載入模組。

針對 Files 中的每個 File,呼叫 compile:file(File, [report_errors, report_warnings]) 來編譯檔案列表。

重新載入所有已載入且在磁碟上已變更的模組(請參閱 mm/0)。傳回針對每個 M 呼叫 l(M) 的結果列表。

列出目前目錄中的檔案。

列出目錄 Dir 中的檔案,如果 Dir 是一個檔案,則僅列出該檔案。

m()

顯示已載入模組的資訊,包括載入它們的檔案。

顯示 Module 的資訊。

記憶體配置資訊。等同於 erlang:memory/0

記憶體配置資訊。等同於 erlang:memory/1

列出所有已修改的模組。 是 code:modified_modules/0 的簡寫。

等同於 nc/2

在所有節點上編譯並載入檔案的程式碼。Options 預設為 []。編譯等同於

i/0 顯示系統資訊,列出有關所有行程的資訊。ni/0 的作用相同,但針對網路中的所有節點。

在所有節點上載入 Module

等同於 regs/0

XYZ 轉換為 pid <X.Y.Z>。此函式僅用於偵錯時。

印出工作目錄的名稱。

q()

此函式是 init:stop() 的簡寫,也就是說,它會導致節點以受控制的方式停止。

regs/0 顯示有關所有已註冊行程的資訊。nregs/0 的作用相同,但針對網路中的所有節點。

以人類可讀的形式印出節點的運作時間(由 erlang:statistics(wall_clock) 指定)。

藉由呼叫 xref:m/1 來尋找模組中未定義的函式、未使用的函式和對已棄用函式的呼叫。

產生 LALR-1 剖析器。等同於

產生 LALR-1 剖析器。等同於

類型

此類型的連結

cmd_line_arg()

檢視原始碼 (未匯出)
-type cmd_line_arg() :: atom() | string().
此類型的連結

h_return()

檢視原始碼 (未匯出)
-type h_return() :: ok | {error, missing | {unknown_format, unicode:chardata()}}.
此類型的連結

hcb_return()

檢視原始碼 (未匯出)
-type hcb_return() :: h_return() | {error, callback_missing}.
此類型的連結

hf_return()

檢視原始碼 (未匯出)
-type hf_return() :: h_return() | {error, function_missing}.
此類型的連結

ht_return()

檢視原始碼 (未匯出)
-type ht_return() :: h_return() | {error, type_missing}.

函式

-spec bt(Pid) -> ok | undefined when Pid :: pid().

顯示行程的堆疊回溯。等同於 erlang:process_display(Pid, backtrace)

-spec c(Module) -> {ok, ModuleName} | error when Module :: file:name(), ModuleName :: module().

作用類似於 c(Module, [])

-spec c(Module, Options) -> {ok, ModuleName} | error
           when
               Module :: file:name(),
               Options :: [compile:option()] | compile:option(),
               ModuleName :: module().

編譯,然後清除並載入模組的程式碼。Module 可以是模組名稱或原始碼檔案路徑,可以帶或不帶 .erl 副檔名。

如果 Module 是字串,則會假設為原始碼檔案路徑,編譯器會嘗試使用選項 Options 編譯原始碼檔案。如果編譯失敗,則會刪除舊的物件檔案(如果有的話)。

如果 Module 是原子,則會尋找具有該確切名稱或帶有 .erl 副檔名的原始碼檔案。如果找到,則會使用選項 Options 編譯原始碼檔案。如果編譯失敗,則會刪除舊的物件檔案(如果有的話)。

如果 Module 是原子,且不是原始碼檔案的路徑,則會搜尋程式碼路徑以找到模組的物件檔案,並擷取其原始編譯器選項和原始路徑。如果在原始位置找不到原始碼檔案,則會使用 filelib:find_source/1 來相對於物件檔案的目錄搜尋它。

編譯原始碼檔案時,會將原始選項附加到給定的 Options,並且只有在編譯成功時,才會將輸出取代舊的物件檔案。

請注意,清除程式碼表示任何停留在該模組舊程式碼中的行程都會在沒有警告的情況下被終止。如需更多資訊,請參閱 code 模組。

此函式的連結

c(Module, Options, Filter)

檢視原始碼 (自 OTP 20.0 起)
-spec c(Module, Options, Filter) -> {ok, ModuleName} | error
           when
               Module :: atom(),
               Options :: [compile:option()],
               Filter :: fun((compile:option()) -> boolean()),
               ModuleName :: module().

編譯,然後清除並載入模組 Module 的程式碼,Module 必須是一個原子。

搜尋程式碼路徑以找到模組 Module 的物件檔案,並擷取其原始編譯器選項和原始路徑。如果在原始位置找不到原始碼檔案,則會使用 filelib:find_source/1 來相對於物件檔案的目錄搜尋它。

編譯原始碼檔案時,會將原始選項附加到給定的 Options,並且只有在編譯成功時,才會將輸出取代舊的物件檔案。函式 Filter 指定要從原始編譯器選項中移除的元素,然後才會加入新的選項。Filter fun 應該針對要保留的選項傳回 true,並針對要移除的選項傳回 false

請注意,清除程式碼表示任何停留在該模組舊程式碼中的行程都會在沒有警告的情況下被終止。如需更多資訊,請參閱 code 模組。

-spec cd(Dir) -> ok when Dir :: file:name().

將工作目錄變更為 Dir,可以是相對名稱,然後印出新的工作目錄名稱。

範例

2> cd("../erlang").
/home/ron/erlang
此函式的連結

erlangrc(PathList)

檢視原始碼 (自 OTP 21.0 起)
-spec erlangrc(PathList) -> {ok, file:filename()} | {error, term()}
                  when PathList :: [Dir :: file:name()].

搜尋 PathList 並載入找到的 .erlang 資源檔。

-spec flush() -> ok.

清除所有傳送到 shell 的訊息。

此函式的連結

h(Module)

檢視原始碼 (自 OTP 23.0 起)
-spec h(module()) -> h_return().

印出 Module 的文件。

此函式的連結

h(Module, Function)

檢視原始碼 (自 OTP 23.0 起)
-spec h(module(), function()) -> hf_return().

印出所有 Module:Function 的文件(不論 arity)。

此函式的連結

h(Module, Function, Arity)

檢視原始碼 (自 OTP 23.0 起)
-spec h(module(), function(), arity()) -> hf_return().

印出 Module:Function/Arity 的文件。

此函式的連結

hcb(Module)

檢視原始碼 (自 OTP 23.0 起)
-spec hcb(module()) -> h_return().

印出 Module 的回呼文件。

此函式的連結

hcb(Module, Callback)

檢視原始碼 (自 OTP 23.0 起)
-spec hcb(module(), Callback :: atom()) -> hcb_return().

印出所有 Module:Callback 的回呼文件(不論 arity)。

此函式的連結

hcb(Module, Callback, Arity)

檢視原始碼 (自 OTP 23.0 起)
-spec hcb(module(), Callback :: atom(), arity()) -> hcb_return().

印出 Module:Callback/Arity 的回呼文件。

-spec help() -> ok.

顯示說明資訊:所有有效的 shell 內部命令和此模組中的命令。

此函式的連結

ht(Module)

檢視原始碼 (自 OTP 23.0 起)
-spec ht(module()) -> h_return().

印出 Module 的類型文件。

此函式的連結

ht(Module, Type)

檢視原始碼 (自 OTP 23.0 起)
-spec ht(module(), Type :: atom()) -> ht_return().

印出 ModuleType 的類型文件,不論 arity。

此函式的連結

ht(Module, Type, Arity)

檢視原始碼 (自 OTP 23.0 起)
-spec ht(module(), Type :: atom(), arity()) -> ht_return().

印出 ModuleType/Arity 的類型文件。

-spec i() -> ok.

等同於 ni/0

-spec i(X, Y, Z) -> [{atom(), term()}]
           when X :: non_neg_integer(), Y :: non_neg_integer(), Z :: non_neg_integer().

顯示行程的資訊,等同於 process_info(pid(X, Y, Z)),但位置透明。

-spec l(Module) -> code:load_ret() when Module :: module().

藉由呼叫 code:purge(Module),然後呼叫 code:load_file(Module) 來清除並載入或重新載入模組。

請注意,清除程式碼意味著任何在模組舊程式碼中徘徊的程序都會在沒有警告的情況下被終止。更多資訊,請參閱 code/3

-spec lc(Files) -> ok | error when Files :: [File :: cmd_line_arg()].

針對 Files 中的每個 File,呼叫 compile:file(File, [report_errors, report_warnings]) 來編譯檔案列表。

關於 File 的資訊,請參閱 file:filename/0

-spec lm() -> [code:load_ret()].

重新載入所有已載入且在磁碟上已變更的模組(請參閱 mm/0)。傳回針對每個 M 呼叫 l(M) 的結果列表。

-spec ls() -> ok.

列出目前目錄中的檔案。

-spec ls(Dir) -> ok when Dir :: file:name().

列出目錄 Dir 中的檔案,如果 Dir 是一個檔案,則僅列出該檔案。

-spec m() -> ok.

顯示已載入模組的資訊,包括載入它們的檔案。

-spec m(Module) -> ok when Module :: module().

顯示 Module 的資訊。

-spec memory() -> [{Type, Size}] when Type :: atom(), Size :: non_neg_integer().

記憶體配置資訊。等同於 erlang:memory/0

-spec memory(Type) -> Size when Type :: atom(), Size :: non_neg_integer();
            (Types) -> [{Type, Size}] when Types :: [Type], Type :: atom(), Size :: non_neg_integer().

記憶體配置資訊。等同於 erlang:memory/1

-spec mm() -> [module()].

列出所有已修改的模組。 是 code:modified_modules/0 的簡寫。

-spec nc(File) -> {ok, Module} | error when File :: file:name(), Module :: module().

等同於 nc/2

-spec nc(File, Options) -> {ok, Module} | error
            when
                File :: file:name(),
                Options :: [Option] | Option,
                Option :: compile:option(),
                Module :: module().

在所有節點上編譯並載入檔案的程式碼。Options 預設為 []。編譯等同於

compile:file(File, Options ++ [report_errors, report_warnings])
-spec ni() -> ok.

i/0 顯示系統資訊,列出有關所有行程的資訊。ni/0 的作用相同,但針對網路中的所有節點。

-spec nl(Module) -> abcast | error when Module :: module().

在所有節點上載入 Module

-spec nregs() -> ok.

等同於 regs/0

-spec pid(X, Y, Z) -> pid() when X :: non_neg_integer(), Y :: non_neg_integer(), Z :: non_neg_integer().

XYZ 轉換為 pid <X.Y.Z>。此函式僅用於偵錯時。

-spec pwd() -> ok.

印出工作目錄的名稱。

-spec q() -> no_return().

此函式是 init:stop() 的簡寫,也就是說,它會導致節點以受控制的方式停止。

-spec regs() -> ok.

regs/0 顯示有關所有已註冊行程的資訊。nregs/0 的作用相同,但針對網路中的所有節點。

此函式的連結

uptime()

檢視原始碼 (自 OTP 18.0 起)
-spec uptime() -> ok.

以人類可讀的形式印出節點的運作時間(由 erlang:statistics(wall_clock) 指定)。

-spec xm(module() | file:filename()) -> XRefMRet :: term().

藉由呼叫 xref:m/1 來尋找模組中未定義的函式、未使用的函式和對已棄用函式的呼叫。

-spec y(file:name()) -> YeccFileRet :: term().

產生 LALR-1 剖析器。等同於

yecc:file(File)

關於 File = name() 的資訊,請參閱 filename。關於 YeccRet 的資訊,請參閱 yecc:file/2

-spec y(file:name(), [yecc:option()]) -> YeccFileRet :: yecc:yecc_ret().

產生 LALR-1 剖析器。等同於

yecc:file(File, Options)

關於 File = name() 的資訊,請參閱 filename。關於 OptionsYeccRet 的資訊,請參閱 yecc:file/2