mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 03:05:30 -04:00
Merge pull request #233 from gamax92/master
Modify option parsing to ignore - and --, add support for equal sign
This commit is contained in:
commit
9d87cdbcb4
@ -11,7 +11,7 @@ computer.pushSignal("init") -- so libs know components are initialized.
|
||||
while true do
|
||||
require("term").clear()
|
||||
io.write(_OSVERSION .. " (" .. math.floor(computer.totalMemory() / 1024) .. "k RAM)\n")
|
||||
local result, reason = os.execute(os.getenv("SHELL") .. " -")
|
||||
local result, reason = os.execute(os.getenv("SHELL"))
|
||||
if not result then
|
||||
io.stderr:write((tostring(reason) or "unknown error") .. "\n")
|
||||
print("Press any key to continue.")
|
||||
|
@ -152,9 +152,13 @@ function shell.parse(...)
|
||||
local options = {}
|
||||
for i = 1, params.n do
|
||||
local param = params[i]
|
||||
if type(param) == "string" and unicode.sub(param, 1, 2) == "--" then
|
||||
if type(param) == "string" and unicode.sub(param, 1, 2) == "--" and param ~= "--" then
|
||||
if param:match("%-%-(.-)=") ~= nil then
|
||||
options[param:match("%-%-(.-)=")] = param:match("=(.*)")
|
||||
else
|
||||
options[unicode.sub(param, 3)] = true
|
||||
elseif type(param) == "string" and unicode.sub(param, 1, 1) == "-" then
|
||||
end
|
||||
elseif type(param) == "string" and unicode.sub(param, 1, 1) == "-" and param ~= "--" and param ~= "-" then
|
||||
for j = 2, unicode.len(param) do
|
||||
options[unicode.sub(param, j, j)] = true
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user