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:
37
issues/05-env-var-access.md
Normal file
37
issues/05-env-var-access.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# 05 — Implement environment variable access (read/write)
|
||||
|
||||
**Status:** open
|
||||
**Blocked by:** #01
|
||||
|
||||
Add syntax for reading and writing environment variables directly from Lua.
|
||||
|
||||
## Option 1 — `export` keyword
|
||||
|
||||
```lua
|
||||
local var = "my data"
|
||||
export var -- exports existing local to env
|
||||
export other_var = "my data" -- creates + exports
|
||||
```
|
||||
|
||||
- New reserved word `export` in lexer
|
||||
- `export var` looks up the local's value by name and calls `setenv()`
|
||||
- `export x = val` combines declaration with `setenv()`
|
||||
|
||||
## Option 2 — `$` sigil
|
||||
|
||||
```lua
|
||||
local dir = $PWD -- getenv("PWD")
|
||||
$PWD = "/" -- setenv("PWD", "/")
|
||||
$MY_ENV_VAR = "data" -- setenv("MY_ENV_VAR", "data")
|
||||
```
|
||||
|
||||
- `$NAME` as expression → `getenv("NAME")`, returns string or `nil`
|
||||
- `$NAME = expr` as statement → `setenv("NAME", tostring(expr))`
|
||||
- New token type in lexer for `$` + identifier
|
||||
|
||||
## Implementation touches
|
||||
|
||||
- `llex.c` / `llex.h` — new token(s) or reserved word
|
||||
- `lparser.c` — new expression/statement rules
|
||||
- Runtime calls `getenv()` / `setenv()` — standard C, no shell needed
|
||||
- Non-existent env var → return `nil`
|
||||
Reference in New Issue
Block a user