Implement $VAR expansion in commands (issue #25)

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)).
This commit is contained in:
Cormac Shannon
2026-03-18 08:35:46 +00:00
parent 635569961e
commit 42baabde34
7 changed files with 98 additions and 13 deletions

1
llex.h
View File

@@ -80,6 +80,7 @@ typedef struct LexState {
TString *envn; /* environment variable name */
TString *brkn; /* "break" name (used as a label) */
TString *glbn; /* "global" name (when not a reserved word) */
TString *cmd_envvar; /* envvar name for $NAME in commands */
lu_byte cmd_mode; /* 0=normal, 1=backtick command, 2=interactive command */
lu_byte saved_cmd_mode; /* cmd_mode to restore after interpolation */
} LexState;