]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_core/commitdiff
telnetd-diag: add 'send' to 'exec' interp. scope
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Mon, 31 Jul 2017 09:04:23 +0000 (05:04 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Mon, 31 Jul 2017 23:23:28 +0000 (19:23 -0400)
telnetd/telnetd-diag.lua

index ec516121e99f30d5f87a3979d944106e55217bf7..e3b238f0f5501b83bf0c6bf02df4713905a4d361 100644 (file)
@@ -6,6 +6,10 @@ return {
   ["fifo"] = function(_,s) if rtcfifo and rtcfifo.ready() ~= 0 then s(string.format("fifo=%d",rtcfifo.count())) else s("no rtcfifo") end end,
   ["exec"] = function(l,s)
        local f, err = loadstring(l)
-       if f then local ok, res = pcall(f); if ok == true then s("ok: "..tostring(res)) else s("pcall err: "..res) end
-         else s("err: "..err) end end
+       if f
+     then getfenv(f).send = function(x) s(tostring(x)) end
+          local ok, res = pcall(f); if ok then s("ok: "..tostring(res)) else s("pcall err: "..res) end
+     else s("err: "..err)
+    end
+   end
 }