#16 multiline shell commands #17 _ scope (global vs local) #18 path expansion (~) #19 nested commands trigger prompt2 #20 simplify backtick return value #21 prompt redesign #22 implicit interactive commands (drop ! prefix) #23 general cleanup and refactor
625 B
625 B
17 — _ is global rather than local
Status: open
The _ result variable from interactive commands (!cmd) is set as a global via lua_setglobal(L, "_"). This has several implications:
- It can escape its scope and pollute other scopes
- A function may silently overwrite
_if it uses shell commands internally, surprising the caller - Lua convention uses
_as a throwaway variable inforloops (for _, v in pairs(t))
Investigation needed
- What are the concrete consequences of
_being global vs local? - Can we make it local to the REPL line instead?
- Should we use a different name entirely?