From 6d2b807fbaa70fd7b8e3895a76180e2d2f6966f6 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 19 Oct 2017 02:11:09 +0200 Subject: [PATCH] lua-simple-uci: fix set()/tset()/section() with empty lists --- libs/lua-simple-uci/src/simple-uci.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libs/lua-simple-uci/src/simple-uci.lua b/libs/lua-simple-uci/src/simple-uci.lua index dfe04fc..8e1dd61 100644 --- a/libs/lua-simple-uci/src/simple-uci.lua +++ b/libs/lua-simple-uci/src/simple-uci.lua @@ -24,14 +24,15 @@ local Cursor = getmetatable(cursor()) local uciset = Cursor.set function Cursor:set(config, section, option, value) - if value ~= nil then + if value ~= nil and not (type(value) == 'table' and #value == 0) then if type(value) == 'boolean' then value = value and '1' or '0' end return uciset(self, config, section, option, value) else - return self:delete(config, section, option) + self:delete(config, section, option) + return true end end @@ -128,9 +129,6 @@ end function Cursor:set_list(config, section, option, value) if config and section and option then - if not value or #value == 0 then - return self:delete(config, section, option) - end return self:set( config, section, option, (type(value) == "table" and value or { value })