Binary is now 'lush', library is 'liblush.a'. Version banner shows
"Lush 0.1.0" with original Lua copyright preserved. Adds LUSH_VERSION
defines and _LUSH_VERSION global. Internal C API names, env vars, and
default paths are unchanged for upstream compatibility.
Tests hardcoded ./lua and assumed CWD was the project root.
Add shared testutil.lua module to derive interpreter path from
arg table, and use temp directories for glob tests instead of
relying on .c files in CWD.
Previously it only set the global _ and returned nothing, which was
surprising when calling it as a function. Now it returns the same
{code, stdout, stderr} table it sets _ to.
Extract lookup_lush_func() in lcmd.c to deduplicate the registry lookup
pattern shared by try_builtin and exec_user_command. Move exec_user_command
after exec_failed to group helpers together. Move codeenvget definition in
lparser.c to replace its forward declaration.
Aliases rewrite the command string before pipeline splitting, so alias
values may contain pipes (e.g. lush.aliases.foo = "echo hi |"). Expansion
happens once per dispatch to prevent recursion.
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.
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.
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.
Extend read_command_body() to detect $NAME and trigger interpolation
using the same fragment-split mechanism as ${expr}. The lexer collects
the identifier into cmd_envvar; the parser's unified parseinterp()
branches on it to emit tostring(getenv(NAME)).
Use cmd_mode (already on LexState) to signal whether interpolation
follows, instead of separate *_INTERP token variants. This eliminates
duplicate simple/interpolated code paths in the parser — commandexp()
and interactivestat() now each use a single unified loop that checks
cmd_mode != 0. A shared parseinterp() helper handles each ${expr}
interpolation cycle.
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.
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.
Unquoted tokens are now expanded through a tilde → brace → glob pipeline
in parse_argv. Quoted tokens (single, double, or backslash) suppress all
expansion. Uses glob(3) with GLOB_NOCHECK for wildcard matching and manual
implementations for tilde (~→$HOME) and brace ({a,b,c}) expansion.
Save and restore cmd_mode across interpolation parsing so that
luaX_readcommandcont resumes in the correct mode after a nested
backtick command inside ${...}.
Revert the bespoke __prompt()/__prompt2() function mechanism from issue
#09 and return to stock Lua's _PROMPT/_PROMPT2 globals (which already
support dynamic prompts via __tostring metatables). Set default
_PROMPT = "lush> " in doREPL if not already defined by config.
Replace static _PROMPT/_PROMPT2 with dynamic __prompt(exitcode)/__prompt2(exitcode)
functions. Fallback chain: __prompt() → _PROMPT → "> ". Install a default __prompt
that shows the current directory with ~ abbreviation. Track last exit code from the
REPL loop and pass it to the prompt function.
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=""}.
Add split_pipeline() to split command strings on unquoted | and
exec_pipeline() to fork N children connected by inter-stage pipes.
Only the last stage's stdout/stderr are captured; middle stages'
stderr is inherited. Exit code comes from the last stage.
Redesign issue #10: bare-word commands now work in both scripts and
the REPL via a parser-level heuristic (identifier + non-exception-list
token → shell command). Add runtime fallback for string-arg syntax
(echo "hello"), double-dash flag handling, and classification examples.
Add issue #12 for path-based command execution (./script, /bin/ls, ~/bin/deploy).
Add testes/lush/commands-interactive.lua as a design playground covering
result table structure, exit codes, commands inside Lua blocks, _ behaviour,
runtime fallback, Lua variable shadowing, and interleaved Lua/shell.
Use sigsetjmp/siglongjmp to catch SIGINT during readline/fgets input
and jump back to the REPL loop with a fresh prompt. Running Lua code
still gets interrupted via the existing laction/lstop mechanism.
Fixes#11.
Rewrite #10 with refined interactive command design: bare-word REPL
fallback instead of ! prefix, result table assigned to _, same shape
as captured commands. Add #11 for Ctrl-C clearing the current line
instead of exiting the REPL.
Use uname -s to select Linux vs macOS build flags instead of
hardcoding. Add -undefined dynamic_lookup for test shared libs
on macOS. Set _port=true automatically on non-Linux in ./all.
Add test suite under testes/lush/ covering backtick commands, argv
parsing, ${} interpolation, and $NAME environment variables. Wire
them into testes/all.lua so they run with the full Lua 5.5 suite.
Skip /dev/full test in files.lua when the device doesn't exist
(macOS has no /dev/full).
Mark issues #02 (backtick lexing/parsing), #03 (command execution
runtime), and #04 (argv parsing) as resolved. Add new issues for
configuration (#08), programmable prompt (#09), and interactive
command execution (#10).
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.