From 8b65619f59c3bdce743c2f2fb2588fdd7079355a Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 8 Aug 2017 03:52:14 +0200 Subject: [PATCH] lua-simple-uci: delete option when using Cursor:set() with nil value Setting the section type when using set() with only two arguments is a very confusing behaviour. section() can be used without a value table for the same result. Deleting the option instead will make set() and get() symmetric and will allow to simplify some code that needed to check for nil to call set() or delete() before. --- libs/lua-simple-uci/src/simple-uci.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/lua-simple-uci/src/simple-uci.lua b/libs/lua-simple-uci/src/simple-uci.lua index 18ebed0..dfe04fc 100644 --- a/libs/lua-simple-uci/src/simple-uci.lua +++ b/libs/lua-simple-uci/src/simple-uci.lua @@ -31,7 +31,7 @@ function Cursor:set(config, section, option, value) return uciset(self, config, section, option, value) else - return uciset(self, config, section, option) + return self:delete(config, section, option) end end @@ -68,7 +68,7 @@ end function Cursor:section(config, type, name, values) local stat = true if name then - stat = self:set(config, name, type) + stat = uciset(self, config, name, type) else name = self:add(config, type) stat = name and true