shelly-shell 0.5.4

A Rust based Unix style shell with a typed and structured language syntax.
# Redirection

Arrows move data left to right. They select streams independently of the typed
pipeline operator.

| Operator | Stream |
| --- | --- |
| `->` | Standard output |
| `~->` | Standard error |
| `~+->` | Both output streams |

A variable target receives captured text. A quoted or interpolated path target is
a file destination. Capture preserves bytes representable as UTF-8, including
trailing newlines; trimming is explicit.

<!-- example: REDIRECT-CAPTURE -->
```shy
let $message: String
let $status = printf 'parcel\n' -> $message
echo $message.count $status
echo $message.trim
```

```text
7 ExecResult(0)
parcel
```


## Files and process input

A String value on the left of a file-reading arrow names a source file.
A value piped into an external program supplies process input. Use a pipe when
passing variable contents rather than reading a filename.

<!-- example: REDIRECT-FILE -->
```shy
printf '%s' "cargo list" -> "manifest.txt"
let $contents: String
"manifest.txt" -> $contents
echo $contents
```

```text
cargo list
```


Redirection is scoped to the command: later output returns to the usual stream.
Keep [execution status](Commands-and-Exit-Status) separate from captured text.
For binary data, use [Bytes and I/O](Bytes-and-IO); String capture is not a binary
container. For bounded child execution with separate files and environment,
use [Process supervision](Process-Supervision).

---

Related: [Pipelines](Pipelines) · [Bytes and I/O](Bytes-and-IO) · [Process supervision](Process-Supervision)