Shell
Run external programs, connect pipelines and capture their output from RecurLoop. Shell passes argument vectors to programs; it does not delegate each command to another shell.
Choose the right operation
| Operation | Where to use it | Result |
|---|---|---|
run | top level or a typed function | exit status |
capture | top level or a typed function | standard output |
spawn | inside a typed function | owned Shell:Invocation* |
Shell:Pipeline | computed argument lists | owned pipeline object |
import shell
run printf "hello\n" | tr a-z A-Z
assert status == 0The output is HELLO. At top level status is a runtime binding. Inside a typed function, assign the return value of run instead of reading that binding.
Do not free borrowed Invocation:stdout text. Do free the string returned by capture inside a typed function. The two APIs deliberately have different ownership.
Learning path
- Commands — Quote arguments and select command syntax.
- Pipelines — Connect streams and handle stage failures.
- Capture and jobs — Collect output and inspect running invocations.
- Command objects — Construct commands from runtime data.
- Process settings — Scope process settings and coordinate parallel jobs.