Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

pi/agent/skillz/nushell/references/external-processes.md

Raw
Rendered preview

External processes

Capture output and status together:

let result = (^tool ...$args | complete)
if $result.exit_code != 0 {
    error make {msg: $"tool exited ($result.exit_code)"}
}
let data = try { $result.stdout | from json --strict } catch {
    error make {msg: "tool returned invalid JSON"}
}

Distinguish process failure, malformed data, valid empty results, and permitted fallback. Never expose raw output that may contain secrets.

See Nu's exit-code and redirection guidance.

# External processes

Capture output and status together:

```nu
let result = (^tool ...$args | complete)
if $result.exit_code != 0 {
    error make {msg: $"tool exited ($result.exit_code)"}
}
let data = try { $result.stdout | from json --strict } catch {
    error make {msg: "tool returned invalid JSON"}
}
```

Distinguish process failure, malformed data, valid empty results, and permitted fallback. Never expose raw output that may contain secrets.

See [Nu's exit-code and redirection guidance](https://www.nushell.sh/book/stdout_stderr_exit_codes.html).