Commit Graph

7 Commits

Author SHA1 Message Date
Cormac Shannon
e115a061bc Remove integer keys from lush table, use string lookups (issue #29)
VM now resolves lush functions via luaH_getshortstr through interned
TString pointers, so wrapping lush.command = my_wrapper is transparently
picked up. The lush table no longer has integer-keyed duplicates.
2026-03-20 21:32:38 +00:00
Cormac Shannon
768de9fe8b Expose lush global as a standard library (issue #26)
Register luaopen_lush() in stdlibs so the lush table is available as a
global. Users can now extend the shell by adding functions to
lush.builtins. The OP_LUSH VM access via integer keys is preserved.
2026-03-18 09:52:56 +00:00
Cormac Shannon
1766e40a68 Implement $(cmd) subcommand syntax in commands (issue #27)
Add $() for inline subcommand substitution that runs a command and
inserts its stdout (trailing newlines stripped) into the outer command
string. Supports nesting, and mixing with ${expr} and $NAME.
2026-03-18 09:29:51 +00:00
Cormac Shannon
f09a033160 Replace upvalue-based shell dispatch with OP_LUSH opcode
Add a dedicated OP_LUSH A B instruction that loads shell C functions
directly from the registry, eliminating the need for upvalue allocation
in mainfunc(), upvalue population in lua_load(), and the fragile
LUSH_NUM_UPVALS heuristic. Every chunk no longer carries 4 extra
upvalues.
2026-03-12 22:47:25 +00:00
Cormac Shannon
f88b17959f Hide shell functions from _G using upvalues on the main chunk
Store __command, __interactive, __getenv, __setenv as upvalues
populated by lua_load() from the registry, keeping them invisible
to user code while accessible to the parser's codegen.
2026-03-12 22:46:56 +00:00
Cormac Shannon
db858b3f68 Implement prefix-based interactive commands via ! (issue #14)
Add !command syntax that runs commands with inherited terminal (no
capture). The lexer treats ! as a statement-starting token, reading
to end-of-line with the same interpolation/escape/pipe support as
backtick commands. The C function sets _ = {code=N, stdout="", stderr=""}.
2026-03-02 22:06:29 +00:00
Cormac Shannon
39d6cc95cb Add command execution runtime (lcmd.c, lcmd.h)
Implements luaB_command: fork/execvp with pipe-captured stdout/stderr,
argv parsing with quoting/escaping, and non-blocking pipe reading via
select(). Backs the __command() calls emitted by the backtick parser.

Resolves #03 and #04.
2026-02-28 18:27:42 +00:00