From 822d6299d6c28fe3780ff40831ec5c00c60133f5 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Sat, 1 Jun 2019 22:12:48 +0200 Subject: 2019-06-01 19:20:00 --- scripts/context/stubs/win64/mtxrun.lua | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'scripts/context/stubs/win64/mtxrun.lua') diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua index 89e23d8ae..f7e67d91e 100644 --- a/scripts/context/stubs/win64/mtxrun.lua +++ b/scripts/context/stubs/win64/mtxrun.lua @@ -25910,7 +25910,7 @@ local helpinfo = [[ run an mtx script (lua prefered method) (), no script gives list - run code passed on the commandline (between quotes) + run code passed on the commandline (between quotes) (=loop) (exit|quit aborts) run a script or program (texmfstart method) () resolve prefixed arguments run internally (using preloaded libs) @@ -26581,16 +26581,22 @@ function runners.associate(filename) end function runners.evaluate(code,filename) -- for Luigi + local environment = table.setmetatableindex(_G) if code == "loop" then while true do - io.write("> ") + io.write("lua > ") local code = io.read() - if code ~= "" then + if code == "quit" or code == "exit" then + break + elseif code ~= "" then local temp = string.match(code,"^= (.*)$") if temp then - code = "print("..temp..")" + code = "inspect("..temp..")" + end + local compiled, message = load(code,"console","t",environment) + if type(compiled) ~= "function" then + compiled = load("inspect("..code..")","console","t",environment) end - local compiled, message = loadstring(code) if type(compiled) ~= "function" then io.write("! " .. (message or code).."\n") else @@ -26603,7 +26609,10 @@ function runners.evaluate(code,filename) -- for Luigi code = filename end if code ~= "" then - local compiled, message = loadstring(code) + local compiled, message = load(code,"console","t",environment) + if type(compiled) ~= "function" then + compiled = load("inspect("..code..")","console","t",environment) + end if type(compiled) ~= "function" then io.write("invalid lua code: " .. (message or code)) return -- cgit v1.2.3