"ruby -wc" vs "ruby -c"

The way to lint a script (that is, to only check its syntax) is to do
“ruby -c”.

But I see in several places[1][2] on the net that people use “ruby -wc”.

I always thought “-w” was for run-time warnings, not for compile-time
ones.

Can anybody give me an example for a Ruby code for which “ruby -wc”
gives different output than “ruby -c”?

[1]
https://github.com/SublimeLinter/SublimeLinter/blob/master/sublimelinter/modules/ruby.py
[2]
http://stackoverflow.com/questions/1302595/ruby-syntax-checking-in-vim/17246442#17246442

On 11/13/2013 04:42 AM, Albert S. wrote:

[1]

https://github.com/SublimeLinter/SublimeLinter/blob/master/sublimelinter/modules/ruby.py

[2]

http://stackoverflow.com/questions/1302595/ruby-syntax-checking-in-vim/17246442#17246442

$ cat test.rb
x = 1
$ ruby -c test.rb
Syntax OK
$ ruby -w -c test.rb
test.rb:1: warning: assigned but unused variable - x
Syntax OK
$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]

Funny, I was just today trying to figure out how to check for syntax
warnings within ruby, when I saw this PR
https://github.com/makaroni4/sandi_meter/pull/29/files#diff-877112234de4a1932929bd1f0413fa93R24
about checking for warnings in JRuby.

So far, it looks like all tools are just shelling out to the ruby
executable. I looked through the Ruby source code but didn’t find where
these checks are done. I found it in Rubinius, but that doesn’t really
help in the general case.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs