shell
host module
Run external commands; opts is required; returns CmdOutput. Replaces wscript-std's process module.
use shell — external commands (replaces wscript-std's process, which is not registered). All take (cmd_or_script: string, opts: Value) and return Result[CmdOutput, string]. opts is required (wscript has fixed arity): pass Value::Null for defaults or a Value::Map with cwd (string), env (map), timeout (int/float secs), stdin (string). Timeout kills the child and returns Err.
| function | behaviour |
|---|---|
| run | splits cmd with shell-words, executes the program directly — no shell interpretation (no globs, pipes, $VAR) |
| run_streaming | like run, but streams output lines through log live (stdout → info, stderr → warn) — for long installs |
| bash | bash -c script (falls back to sh) — the shell-features escape hatch |
| powershell | tries powershell then pwsh with -NoProfile -NonInteractive; works on Linux with PowerShell Core |
§ 1.1CmdOutput
rust
use shell
use value
let out = run?
if !out.success
Non-zero exit is not an Err
Inspect out.success/out.code. Err means the command could not run (spawn failure, timeout).