# Recommended command line options for new rubyists

**URL:** <https://www.ruby-forum.com/t/recommended-command-line-options-for-new-rubyists/51635>\
**Category:** Ruby\
**Created:** [January 4, 2006, 8:21pm UTC](https://www.ruby-forum.com/t/recommended-command-line-options-for-new-rubyists/51635 "2006-01-04T20:21:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [January 4, 2006, 8:21pm UTC](https://www.ruby-forum.com/t/recommended-command-line-options-for-new-rubyists/51635/1 "2006-01-04T20:21:30Z")

</div>

Hi guys,

There are loooads of ruby docs out there. There are also some good  
reference guides under /usr/share/doc/ruby-1.8.3,  
/usr/share/doc/ruby-docs-1.8.3 and /usr/share/doc/ruby-libs-1.8.3. What  
would the more experienced of you recommend for command line options? So  
far I’ve been using  
ruby -c foo.rb  
ruby -W foo.rb  
as they are the simplest 🙂 I’ve not really used irb that much as I  
haven’t seen any advantage in using it.

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [January 4, 2006, 8:27pm UTC](https://www.ruby-forum.com/t/recommended-command-line-options-for-new-rubyists/51635/2 "2006-01-04T20:27:35Z")

</div>

Hi –

On Thu, 5 Jan 2006, John M. wrote:

> haven’t seen any advantage in using it.  
> The ones I use the most are:

ruby -cw  
ruby -v[e]  
ruby -e  
ruby -p[i.bak][-e]  
ruby -n[i.bak][-e]

David

–  
David A. Black  
removed\_email\_address@domain.invalid

“Ruby for Rails”, from Manning Publications, coming April 2006!

> **[Ruby for Rails](https://www.manning.com/books/ruby-for-rails)**
>
> NEWER EDITION AVAILABLE
> 
> The Well-Grounded Rubyist, Second Edition is now available. An eBook of the previous edition, The Well-Grounded Rubyist is included at no additional cost when you buy the revised edition! 
> 
> 
> Ruby for Rails helps Rails...

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [January 4, 2006, 10:16pm UTC](https://www.ruby-forum.com/t/recommended-command-line-options-for-new-rubyists/51635/3 "2006-01-04T22:16:02Z")

</div>

Hi –

On Thu, 5 Jan 2006, John M. wrote:

> I find it strange that ruby -c foo.rb gives “syntax OK” but ruby -w  
> foo.rb shows me all of the syntax errors. In the example below i  
> make a deliberate mistake…

You do, but it’s not a syntax error; it’s a runtime error. -c doesn’t  
run the code, but only checks it for syntax. -w runs the code.

## David

David A. Black  
removed\_email\_address@domain.invalid

“Ruby for Rails”, from Manning Publications, coming April 2006!

> **[Ruby for Rails](https://www.manning.com/books/ruby-for-rails)**
>
> NEWER EDITION AVAILABLE
> 
> The Well-Grounded Rubyist, Second Edition is now available. An eBook of the previous edition, The Well-Grounded Rubyist is included at no additional cost when you buy the revised edition! 
> 
> 
> Ruby for Rails helps Rails...

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [January 4, 2006, 10:10pm UTC](https://www.ruby-forum.com/t/recommended-command-line-options-for-new-rubyists/51635/4 "2006-01-04T22:10:01Z")

</div>

I find it strange that ruby -c foo.rb gives “syntax OK” but ruby -w  
foo.rb shows me all of the syntax errors. In the example below i make a  
deliberate mistake…

#script

#!/usr/bin/ruby  
#Wed Jan 4 06:17:22 GMT 2006  
class Menu  
def initialize(welcome, stage, usage)  
@welcome = print “Welcome to  
de-blah-de-blah-de-blah\n\n\n”  
@usage = usage # we will use this as a user  
guide  
@stage = stage  
#`date`  
#print “which stage are you at?  
#b:- before site work  
#d:- during site work  
#a:- atfer site work  
#q:- quit!\n”  
end  
def to\_s  
“Deskstudy: #@welcome #@usage #@stage”  
end  
end

#menu = Menu.new(“welcome”, “usage”, “stage”)  
menu = Menu.new(“welcome”, “stage”)  
menu.inspect  
puts menu

#errors

menu.rb:21:in `initialize’: wrong number of arguments (2 for 3)  
(ArgumentError)  
from menu.rb:21

On Thu, 5 Jan 2006 04:25:54 +0900

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [January 5, 2006, 6:48pm UTC](https://www.ruby-forum.com/t/recommended-command-line-options-for-new-rubyists/51635/5 "2006-01-05T18:48:42Z")

</div>

unknown wrote:

> Hi –
> 
> On Thu, 5 Jan 2006, John M. wrote:
> 
> > I find it strange that ruby -c foo.rb gives “syntax OK” but ruby -w  
> > foo.rb shows me all of the syntax errors. In the example below i  
> > make a deliberate mistake…
> 
> You do, but it’s not a syntax error; it’s a runtime error. -c doesn’t  
> run the code, but only checks it for syntax. -w runs the code.

Or to give a simpler testcase:

$ cat div0  
#!/usr/bin/env ruby  
puts 5/0

$ ruby -c div0  
Syntax OK

$ ruby -w div0  
div0:2:in `/’: divided by 0 (ZeroDivisionError)  
from div0:2
