Files
lush/issues/06-piping.md
Cormac Shannon db6f39a2a4 Add project issues for lush (Lua + shell) features
Defines syntax decisions and implementation plan across 7 issues:
- backtick command execution returning {code, stdout, stderr}
- ${expr} interpolation in backticks
- $SIGIL env var read/write
- argv parsing, piping, and redirection (future)
2026-02-18 19:08:59 +00:00

26 lines
727 B
Markdown

# 06 — Implement piping between commands
**Status:** open (post-core)
**Blocked by:** #03, #04
## Syntax
```lua
local result = `ls -l` | `grep ".lua"`
```
## Implementation
- Connect stdout of one child to stdin of the next via `pipe()` + `dup2()`
- Build a pipeline of N processes, all forked and connected
- Only capture stdout/stderr of the **final** process
- `waitpid()` all children, return exit code of last process
## Challenge
Lua uses `|` for bitwise OR. The parser needs to disambiguate:
- `|` between two command expressions → pipe
- `|` between numeric expressions → bitwise OR
This is resolvable because the parser knows the type of each subexpression — a backtick expression is always a command.