mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-22 23:42:59 +00:00
split_shell: automatically trim whitespace; ignore args that consist solely of whitespace
Hence "//bonemeal 1 4 " now functions correctly
This commit is contained in:
parent
462570f2eb
commit
f1a433b5e3
1 changed files with 5 additions and 2 deletions
|
@ -5,7 +5,7 @@ local function is_whitespace(char)
|
||||||
return char:match("%s")
|
return char:match("%s")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function split_shell(text)
|
local function split_shell(text, autotrim)
|
||||||
local text_length = #text
|
local text_length = #text
|
||||||
local scan_pos = 1
|
local scan_pos = 1
|
||||||
local result = { }
|
local result = { }
|
||||||
|
@ -26,7 +26,10 @@ local function split_shell(text)
|
||||||
|
|
||||||
if mode == "NORMAL" then
|
if mode == "NORMAL" then
|
||||||
if is_whitespace(curchar) and #acc > 0 then
|
if is_whitespace(curchar) and #acc > 0 then
|
||||||
|
local nextval = worldeditadditions.trim(table.concat(acc, ""))
|
||||||
|
if #nextval > 0 then
|
||||||
table.insert(result, table.concat(acc, ""))
|
table.insert(result, table.concat(acc, ""))
|
||||||
|
end
|
||||||
acc = {}
|
acc = {}
|
||||||
elseif (curchar == "\"" or curchar == "'") and #acc == 0 and prevchar ~= "\\" then
|
elseif (curchar == "\"" or curchar == "'") and #acc == 0 and prevchar ~= "\\" then
|
||||||
if curchar == "\"" then
|
if curchar == "\"" then
|
||||||
|
|
Loading…
Reference in a new issue