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.
This commit is contained in:
4
linit.c
4
linit.c
@@ -45,7 +45,7 @@ static const luaL_Reg stdlibs[] = {
|
||||
|
||||
/*
|
||||
** Store shell functions in a registry table at LUA_RIDX_LUSH.
|
||||
** Integer keys 1..4 hold the C functions (accessed by OP_LUSH).
|
||||
** Integer keys 1..5 hold the C functions (accessed by OP_LUSH).
|
||||
** String key "builtins" holds the builtins table (set by luaopen_builtins).
|
||||
*/
|
||||
static void opencommand (lua_State *L) {
|
||||
@@ -58,6 +58,8 @@ static void opencommand (lua_State *L) {
|
||||
lua_rawseti(L, -2, LUSH_OP_GETENV + 1);
|
||||
lua_pushcfunction(L, lushCmd_setenv);
|
||||
lua_rawseti(L, -2, LUSH_OP_SETENV + 1);
|
||||
lua_pushcfunction(L, lushCmd_subcmd);
|
||||
lua_rawseti(L, -2, LUSH_OP_SUBCMD + 1);
|
||||
lua_rawseti(L, LUA_REGISTRYINDEX, LUA_RIDX_LUSH);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user