From 579db9babf5aea62e1572bcb682c681a8552436c Mon Sep 17 00:00:00 2001
From: David Perry <boolean263@protonmail.com>
Date: Wed, 20 Jan 2021 08:19:37 -0500
Subject: [PATCH] Lua: make evaluate_lua and run_console public

Fixes #12250 by allowing people debugging their dissector to add a call
to `run_console()` at the start of their plugin, so they can see error
messages triggered on plugin init.
---
 epan/wslua/console.lua | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/epan/wslua/console.lua b/epan/wslua/console.lua
index d2635ef5fbc..c0f404ef9bb 100644
--- a/epan/wslua/console.lua
+++ b/epan/wslua/console.lua
@@ -10,18 +10,20 @@
 -- SPDX-License-Identifier: GPL-2.0-or-later
 
 
-if (gui_enabled()) then 
-	-- Note that everything is "local" to this "if then" 
-	-- this way we don't add globals
+if (gui_enabled()) then
+	-- Note that evaluate_lua and run_console are NOT "local"
+	-- to allow them to be used in scripts (#12250)
+	-- Everything else is "local" to this "if then"
+	-- this way we don't add extra globals
 
 	-- Evaluate Window
-	local function evaluate_lua()
+	function evaluate_lua()
 		local w = TextWindow.new("Evaluate Lua")
 		w:set_editable()
 
 		-- button callback
 		local function eval()
-			-- get the window's text and remove the result 
+			-- get the window's text and remove the result
 			local text = string.gsub(w:get_text(),"%c*--%[%[.*--%]%]$","")
 
 			-- if the text begins with '=' then convert = into return
@@ -50,7 +52,7 @@ if (gui_enabled()) then
 	end
 
 	-- Console Window
-	local function run_console()
+	function run_console()
 		if console_open then return end
 		console_open = true
 
-- 
GitLab