From d6122ce3a54ca33b519640746d64e1711ef4cebb Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 11 Aug 2021 14:55:59 +0200 Subject: mod_admin_shell: Keep unrestricted environment for session lifetime Makes it so that global values set in the environment are kept longer than within one line, and thus can be used until the session ends. They still don't pollute the global environment, which is an error anyway. Thanks phryk for noticing. --- plugins/mod_admin_shell.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua index 3b1ce277..bab5c4b2 100644 --- a/plugins/mod_admin_shell.lua +++ b/plugins/mod_admin_shell.lua @@ -135,8 +135,12 @@ local function handle_line(event) return; end + if useglobalenv and not session.globalenv then + session.globalenv = redirect_output(_G, session); + end + local chunkname = "=console"; - local env = (useglobalenv and redirect_output(_G, session)) or session.env or nil + local env = (useglobalenv and session.globalenv) or session.env or nil -- luacheck: ignore 311/err local chunk, err = envload("return "..line, chunkname, env); if not chunk then -- cgit v1.2.3