$DEBUG variable in Ruby

In Ruby script, when to interpreter -d option is supplied (from command line or in #! line on the script start) global $DEBUG flag is set. This can be used to produce Your own debug output, like:

puts "You are here" if $DEBUG

But setting this flag changes behaviour of ruby interpreter itself. It has some implication on how exceptions in threads are handled (but with this I have no experience, since I have not used threads in Ruby yet) but also all exceptions are reported to STDERR, even with proper rescue clause.

For example see this thread: http://www.ruby-forum.com/topic/75920

Join the Conversation

2 Comments

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.