From d930cdc295d709883a722f43a540a239254aa458 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Sat, 24 Feb 2018 03:47:04 +0000 Subject: [PATCH] lualoader: Add comment on trailing space, don't operate on nil Functionally, the latter error wouldn't necessarily hurt anything. io.write will just error out as it's not passed a valid file handle. Still, we can do better than that. --- stand/lua/config.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/stand/lua/config.lua b/stand/lua/config.lua index 5c3d25031244..46b911228815 100644 --- a/stand/lua/config.lua +++ b/stand/lua/config.lua @@ -141,8 +141,14 @@ local function check_nextboot() end local nfile = io.open(nextboot_file, 'w') - io.write(nfile, "nextboot_enable=\"NO\" ") - io.close(nfile) + if nfile ~= nil then + -- We're overwriting the first line of the file, so we need the + -- trailing space to account for the extra character taken up by + -- the string nextboot_enable="YES" -- our new end quotation + -- mark lands on the S. + io.write(nfile, "nextboot_enable=\"NO\" ") + io.close(nfile) + end end -- Module exports