Skip to content

Instantly share code, notes, and snippets.

@duckinator
Created January 28, 2012 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duckinator/1691948 to your computer and use it in GitHub Desktop.
Save duckinator/1691948 to your computer and use it in GitHub Desktop.
$ ./loader.rb input.rb
hi
true
$
puts 'hi'
'lololol'
#!/usr/bin/env ruby
require 'stringio'
file = ARGV[0]
exit 1 if ARGV.length == 0
$stdout = $stderr = StringIO.new
ret = begin
load file
rescue Exception => e
"#{e.class}: #{e.message}"
end
out = $stdout.string
$stdout = STDOUT
$stderr = STDERR
puts out
puts ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment