#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
16 lines
625 B
Markdown
16 lines
625 B
Markdown
# 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 in `for` loops (`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?
|