I need to run a script in a special environment. I need to change
how STDIN works, for example, to fetch responses from GUI. That’s
easily done and can be made to work via a simple:
ruby -r my_special_env script_to_run.rb
However, one element keeps tripping me up. My special environment
must also catch exceptions not handled by the script, for error
reporting purposes. Is there any way to do the via a require?
The best idea I have so far is to add a begin … rescue … end around
the code in the script and then execute it, but this seems mighty
clumsy when you take into account things like the working directory,
the script name, and line number offsets. It’s doable, but I would
love to find a more elegant solution.
Any ideas you can provide are appreciated.
James Edward G. II