Forum: Ruby "ruby -wc" vs "ruby -c"

699c00ad35f2755810b4aa5f423d73e2?d=identicon&s=25 Albert Schlef (alby)
on 2013-11-13 13:42
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

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

6e366eb5a71be2bad7f383d42aeb4788?d=identicon&s=25 Justin Collins (Guest)
on 2013-11-13 17:23
(Received via mailing list)
On 11/13/2013 04:42 AM, Albert Schlef wrote:
> [1]
> [2]

$ 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]
B5c20f697f141bfc00b1b57e581101c9?d=identicon&s=25 Benjamin F. (benjamin_f)
on 2013-11-14 03:29
Funny, I was just today trying to figure out how to check for syntax
warnings within ruby, when I saw this PR
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.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.