Advertisement
Symmetryc

Safe Shell

Jan 31st, 2014
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.41 KB | None | 0 0
  1. setfenv(loadfile("/rom/programs/shell"),
  2.     setmetatable(
  3.         {
  4.             pcall = function(_f, ...)
  5.                 local env = getfenv(_f)
  6.                 env.shell = env.shell or shell
  7.                 local co = coroutine.create(_f)
  8.                 local err, ok = coroutine.resume(co, ...)
  9.                 while err and coroutine.status(co) ~= "dead" do
  10.                     err, ok = coroutine.resume(co, coroutine.yield())
  11.                 end
  12.                 return ok
  13.             end;
  14.         },
  15.         {
  16.             __index = _G
  17.         }
  18.     )
  19. )()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement