Closed SoniEx2 closed 6 years ago
Then just add =
... The point is that it's meant to be compatible with the real shell, and it's not.
On Wed, 6 Apr 2016, 12:11 AM Setsuna F Seiei notifications@github.com wrote:
Then just add =
— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/MightyPirates/OpenComputers/issues/1661#issuecomment-205827370
Thing is, I try to not make changes to OpenOS that are 5.2 or 5.3 specific. The only case we currently have is the bit32 lib that loads conditionally due to the machine _G environment providing the library conditionally based on the Lua version of the cpu. But the result of this effort is that both archs have bit32, it makes them common. Basically, you're asking a tool, in the OS, to behave differently when a different CPU is inserted.
I would be more in favor of not requiring = for either CPU.
EDIT In other words, we aren't emulating the 5.2 shell on a 5.2 CPU and the 5.3 on a 5.3 CPU, we're just emulating a Lua prompt in the /bin/lua script.
FWIW I'd be fine with making the =
optional. I.e. make it work either way (have it replace =
with return
as before, if there's no =
try running the input, if it fails, try running it again with return
prefixed, if that also fails return first error).
Running line two times is deep rabbit hole that you might not be willing to go as modification of global state could be performed two times.
Yes, you're supposed to check syntax errors returned by load().
if str:sub(1,1) == "=" then str = "return " .. str:sub(2) end
local chunk, err = load("return " .. str)
if not chunk then
chunk, err = load(str)
end
if not chunk then
-- check for multiline input
end
-- run chunk/print syntax errors/etc
see also #1662
Yeah, I should have said 'loading' instead of 'running', my bad.
we resolved this now
Real Lua 5.3 shell doesn't require "=" at the start, it'll simply check for an expression.