From: Kedar Mhaswade Date: 2010-12-22T00:05:41+09:00 Subject: Re: debug flag being ignored rickhg12hs wrote in post #131750: >> I'm trying to run 'ruby -d foo.rb' and the d is either ignored or I don't >> understand how it works. The code just runs as if there is no -d option. > > "-d" sets $DEBUG to true. > > Does your code execute something when $DEBUG is true? > > For example: > > puts "Important intermediate value: #{my_critical_var}" if $DEBUG I was going nuts over this. This file: #!/usr/bin/env ruby puts $DEBUG prints false with or without ruby -d (e.g. ruby -d foo.rb) So, the shebang line comes in the way in an unpredictable manner. The workaround is to have export RUBYOPT=-d $RUBYOPT if you wanted shebang line (and the easier invocation like: ./foo.rb after chmoding it). If you are giving your file to the interpreter directly like: ruby foo.rb (*and* you don't have shebang line in the file), then ruby -d works as expected. Bottom line: For such a simple thing, shebang line complicates life (unnecessarily) at least on Linux :( -- Posted via http://www.ruby-forum.com/.