mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 11:15:12 -04:00
Make shell stop parsing options at --
.
This commit is contained in:
parent
9d87cdbcb4
commit
54cc679c37
@ -150,17 +150,24 @@ function shell.parse(...)
|
||||
local params = table.pack(...)
|
||||
local args = {}
|
||||
local options = {}
|
||||
local doneWithOptions = false
|
||||
for i = 1, params.n do
|
||||
local param = params[i]
|
||||
if type(param) == "string" and unicode.sub(param, 1, 2) == "--" and param ~= "--" then
|
||||
if param:match("%-%-(.-)=") ~= nil then
|
||||
options[param:match("%-%-(.-)=")] = param:match("=(.*)")
|
||||
if not doneWithOptions and type(param) == "string" then
|
||||
if param == "--" then
|
||||
doneWithOptions = true -- stop processing options at `--`
|
||||
elseif unicode.sub(param, 1, 2) == "--" then
|
||||
if param:match("%-%-(.-)=") ~= nil then
|
||||
options[param:match("%-%-(.-)=")] = param:match("=(.*)")
|
||||
else
|
||||
options[unicode.sub(param, 3)] = true
|
||||
end
|
||||
elseif unicode.sub(param, 1, 1) == "-" and param ~= "-" then
|
||||
for j = 2, unicode.len(param) do
|
||||
options[unicode.sub(param, j, j)] = true
|
||||
end
|
||||
else
|
||||
options[unicode.sub(param, 3)] = true
|
||||
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
|
||||
table.insert(args, param)
|
||||
end
|
||||
else
|
||||
table.insert(args, param)
|
||||
|
Loading…
x
Reference in New Issue
Block a user