Debugging 运行Ruby脚本时如何设置$DEBUG变量

Debugging 运行Ruby脚本时如何设置$DEBUG变量,debugging,command-line-arguments,Debugging,Command Line Arguments,我尝试运行脚本test.rb,其中包含: puts "Debugging" if $DEBUG 使用命令: > ruby test.rb --debug --debug开关似乎没有效果。有什么好处?嗯。。。调试参数需要传递给Ruby > ruby --debug test.rb 正常工作。这确实正常工作:ruby-e“放入$DEBUG”--DEBUG

我尝试运行脚本test.rb,其中包含:

puts "Debugging" if $DEBUG
使用命令:

> ruby test.rb --debug

--debug开关似乎没有效果。有什么好处?

嗯。。。调试参数需要传递给Ruby

> ruby --debug test.rb

正常工作。

这确实正常工作:
ruby-e“放入$DEBUG”--DEBUG