我优先使用#!/bin/env ruby
来调用Ruby脚本,它允许我使用本地Ruby安装而不会与系统Ruby安装冲突。但是我怎样才能在Linux系统上启用警告?我的测试脚本:如何运行启用了env和warnings的Ruby脚本?
#!/usr/bin/env ruby -w
FOO
在Mac上,我得到:
[email protected]:~$ ./test.rb
./test.rb:3: warning: possibly useless use of a constant in void context
./test.rb:3:in `<main>': uninitialized constant FOO (NameError)
在Linux上,我得到:
[email protected]:~$ ./test.rb
/usr/bin/env: ruby -w: No such file or directory
我已经注意到设置'export RUBYOPT = -w'的可能性,但是我想尽量避免这种情况。 – maasha 2013-02-21 10:58:25
关于ruby论坛上的主题有一个线程:http://www.ruby-forum.com/topic/96121 – maasha 2013-02-21 11:11:40
更多关于env和多个参数在这里:http://stackoverflow.com/questions/4303128/how-使用多个参数与一个shebang,即 – maasha 2013-02-21 11:13:28