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)
26 lines
727 B
Markdown
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.
|