Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   "-version" produced curious result; "--version" ran as expected" -- why? (http://www.velocityreviews.com/forums/t828162-version-produced-curious-result-version-ran-as-expected-why.html)

Richard Lionheart 01-28-2006 01:55 AM

"-version" produced curious result; "--version" ran as expected" -- why?
 
Hi All,

I just expanded ruby-1.8.4-i386-mswin32.zip into my Utilities directory and
added it bin subdirectory to my PATH.

In a Command window, I entered/got:

F:\> ruby -version

ruby 1.8.4 (2005-12-24) [i386-mswin32]

ruby: no such file to load -- ubygems (LoadError)



F:\>


Why did ruby want to load "ubygems"? BTW, I happened to notice an
environment variable RUBYOPT set to rubygems (left over from a previous
installation, no doubt.)

I then recalled the options should have double hyphens, so --version didn't
produce that spurious line.

Any explanation? Not critical. Just curious.
--
TIA,
Richard



Daniel Calvelo 01-28-2006 08:01 PM

Re: "-version" produced curious result; "--version" ran as expected" -- why?
 
Remember that, being of UNIX lineage, ruby follows its conventions. One
of those conventions is options vs. long-options. Long options I think
were a GNU invention, intended to make command options (traditionally
one letter after hyphen) more mnemonic. Long options start with double
hyphens, and short options with one. A single double hyphen signals the
end of options. Thus the long-option equivalent of "-v" is "--version".

"-version" as an option is parsed as a compound of "-x" options with x
in v,e,r,s,i,o,n; -e -i and -r require parameters, so they should parse
the following command-line arguments as their parameters.

My guess: RUBYOPT is additional options, and is "pasted-in" the
command-line. So one of e,i options ate the "r" from 'rubygems' and
then the -r option tried to load the library 'ubygems'.

Experiment a little and you might understand exacly how the option
parameters are used, and in what order.

Daniel.


Richard Lionheart 01-28-2006 09:01 PM

Re: "-version" produced curious result; "--version" ran as expected" -- why?
 
Hi Daniel,

Understood! Thanks for the clear,comprehensive and timely response.

Regards,
Richard

"Daniel Calvelo" <dca.gis@gmail.com> wrote in message
news:1138478510.332905.132100@g47g2000cwa.googlegr oups.com...
> Remember that, being of UNIX lineage, ruby follows its conventions. One
> of those conventions is options vs. long-options. Long options I think
> were a GNU invention, intended to make command options (traditionally
> one letter after hyphen) more mnemonic. Long options start with double
> hyphens, and short options with one. A single double hyphen signals the
> end of options. Thus the long-option equivalent of "-v" is "--version".
>
> "-version" as an option is parsed as a compound of "-x" options with x
> in v,e,r,s,i,o,n; -e -i and -r require parameters, so they should parse
> the following command-line arguments as their parameters.
>
> My guess: RUBYOPT is additional options, and is "pasted-in" the
> command-line. So one of e,i options ate the "r" from 'rubygems' and
> then the -r option tried to load the library 'ubygems'.
>
> Experiment a little and you might understand exacly how the option
> parameters are used, and in what order.
>
> Daniel.
>





All times are GMT. The time now is 01:07 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.