Skip to content

Instantly share code, notes, and snippets.

@oneup
Created July 6, 2009 00:48
Show Gist options
  • Save oneup/141203 to your computer and use it in GitHub Desktop.
Save oneup/141203 to your computer and use it in GitHub Desktop.
def safe_eval(text)
begin
Kernel.eval(text)
rescue Exception => e
"Exception " + e.to_s
rescue SyntaxError => e
"Syntax Error #{e}"
rescue Error => e
"Error #{e}"
rescue NameError => e #"multicast" nameerror, so inventory can caputre it
"NameError #{e}"
end
end
while true
something = gets.strip
safe_eval something
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment