split_shell: automatically trim whitespace; ignore args that consist solely of whitespace

Hence "//bonemeal       1     4     " now functions correctly
This commit is contained in:
Starbeamrainbowlabs 2021-12-28 01:27:39 +00:00
parent 462570f2eb
commit f1a433b5e3
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2

@ -5,7 +5,7 @@ local function is_whitespace(char)
return char:match("%s")
end
local function split_shell(text)
local function split_shell(text, autotrim)
local text_length = #text
local scan_pos = 1
local result = { }
@ -26,7 +26,10 @@ local function split_shell(text)
if mode == "NORMAL" 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, ""))
end
acc = {}
elseif (curchar == "\"" or curchar == "'") and #acc == 0 and prevchar ~= "\\" then
if curchar == "\"" then