本文へ移動
mie リファレンス
REPL Playground

std:process リファレンス

@import 'std:process' で取得するサブプロセス実行モジュール。外部コマンドの実行 (exec / run / run_opts) を提供する。

exec

exec(argv)
exec: { List(String) | Future(Result({ code, stdout, stderr |})) }

argv を shell を介さず直接起動する (注入安全)。

>>> result := process.exec(["echo", "hi"])!
>>> print result

run

run(cmd)
run: { String | Future(Result({ code, stdout, stderr |})) }

cmd を shell 経由 (sh -c) で実行する。exit 0 は Ok、非 0 は Err。

>>> result := process.run("echo hi")!
>>> print result

run_opts

run_opts(opts)
run_opts: { Any | Future(Result({ code, stdout, stderr |})) }

opts で cmd|argv / cwd / env / stdin / stdio を指定して実行する。stdio := 'inherit' は親の標準入出力へ直結する (ライブ出力・対話用。既定 'capture')。

>>> process.run_opts({ argv := ["ls", "-l"], cwd := "/tmp" |})!
>>> process.run_opts({ cmd := "go test ./...", stdio := "inherit" |})!