``In the Beginning was the Command Line.''[Title of a
marvelous essay by Neal Stephenson
(available online at
Regardless of the system in which Ruby is deployed, whether it be a
super high-end scientific graphics workstation or an embedded PDA
device, you've got to start the Ruby interpreter somehow, and that
gives us the opportunity to pass in command-line arguments.
A Ruby command line consists of three parts: options to the Ruby
interpreter, optionally the name of a program to run, and optionally a
set of arguments for that program.
] [--] [
The Ruby options are terminated by the first word on the command line
that doesn't start with a hyphen, or by the special flag ``
If no filename is present on the command line, or if the filename is
a single hyphen (
), Ruby reads the program source from standard
Arguments for the program itself follow the program name. For example:
% ruby -w - "Hello World"
will enable warnings, read a program from standard input, and pass it
the quoted string
as an argument.