From b0f7568a40557698e552da52c72b9d6258ac29c3 Mon Sep 17 00:00:00 2001 From: SinisterRectus Date: Tue, 17 Jan 2023 19:44:55 -0500 Subject: [PATCH] Adds some nil checks --- samples/repl.app/repl.lua | 4 +++- samples/repl.app/utils.lua | 1 + src/lua/luvibundle.lua | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/samples/repl.app/repl.lua b/samples/repl.app/repl.lua index 5053a69a..302f3525 100644 --- a/samples/repl.app/repl.lua +++ b/samples/repl.app/repl.lua @@ -18,6 +18,8 @@ limitations under the License. return function (stdin, stdout, uv, utils, greeting) + local loadstring = loadstring or load + local print = function(...) uv.write(stdout, table.concat({...}, "\t") .. "\n") end @@ -67,7 +69,7 @@ return function (stdin, stdout, uv, utils, greeting) end else - if err:match "''$" then + if err and err:match "''$" then -- Lua expects some more input; stow it away for next time buffer = chunk .. '\n' return '>>' diff --git a/samples/repl.app/utils.lua b/samples/repl.app/utils.lua index e571284d..d47453ac 100644 --- a/samples/repl.app/utils.lua +++ b/samples/repl.app/utils.lua @@ -1,6 +1,7 @@ local uv = require('uv') local env = require('env') +local unpack = unpack or table.unpack local prettyPrint, dump, strip, color, colorize, loadColors local theme = {} local useColors = false diff --git a/src/lua/luvibundle.lua b/src/lua/luvibundle.lua index 5e4b7b66..9d028abf 100644 --- a/src/lua/luvibundle.lua +++ b/src/lua/luvibundle.lua @@ -144,7 +144,7 @@ local function zipBundle(base, zip) -- Support zips with a single folder inserted at top-level local entries = bundle.readdir("") - if #entries == 1 and bundle.stat(entries[1]).type == "directory" then + if entries and #entries == 1 and bundle.stat(entries[1]).type == "directory" then chrootBundle(bundle, entries[1] .. '/') end