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)
This commit is contained in:
Cormac Shannon
2026-02-18 19:08:51 +00:00
parent 4cf498210e
commit db6f39a2a4
7 changed files with 249 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
# 03 — Implement direct command execution runtime (no shell)
**Status:** open
**Blocked by:** #02
**Blocks:** #06, #07
Implement the C runtime that executes commands when a backtick expression is evaluated.
**Critical constraint:** do NOT spawn a shell (no `bash`, `dash`, `sh`, `system()`, `popen()`).
## Return value
Backtick expressions return a table:
```lua
local r = `ls -lha`
r.code -- exit code (integer)
r.stdout -- captured stdout (string)
r.stderr -- captured stderr (string)
```
## Implementation approach
- `fork()` + `execvp()` on Unix/macOS
- Set up two pipes: one for stdout, one for stderr
- In child: `dup2()` pipes onto fd 1 and fd 2, then `execvp(argv[0], argv)`
- In parent: read both pipes into buffers, `waitpid()` for exit status
- Build a Lua table with `code`, `stdout`, `stderr` fields and push onto stack
- Depends on #04 (argv parsing) to tokenize the command string into argv[]
## Error handling
- Command not found → set `code` to an error value, `stderr` to error message
- Permission denied → same
- `fork()` failure → raise a Lua error
## Open questions
- New file (`lcmd.c` / `lcmd.h`) or add to an existing lib?
- Signal handling during child execution
- Binary output — return raw string bytes as-is?
- Set `__tostring` metamethod on result table?