Command line arguments in windows

If I execute my apps from a command line using a syntax like this

ruby my_app arg1 arg2 … argx

then all passed in arguments are handled correctly.

If I execute my apps from a command line using this syntax

my_app arg1 arg2 … argx

then ARGV is empty!

.rb exists in my PATHEXT system variable so it should be treated the
same as
a .exe. Anyone else encountered this?

Thanks,
Joe

On Wed, 16 Aug 2006 22:50:03 +0200, Joe S. [email protected]
wrote:

then ARGV is empty!

.rb exists in my PATHEXT system variable so it should be treated the
same as
a .exe. Anyone else encountered this?

Thanks,
Joe

Not really. PATHEXT just means that try to append those extensions to a
command you enter on the command line, and then invoke the default
opener
for that file type.

The opener for ruby could be set up to run “ruby %1”, where %1 is only
the
script file name. I don’t have a Ruby installed on my Windows boot right
now, but poke around the registry looking for what filetype the “.rb”
extension is registered to, and then search for the name of the filetype
to scrounge up what the command string is.

My memory of last doing something like this is a little vague, so no
exact
syntax - but I do think the filetype opener settings use batch file
syntax, and then you should use %* in place of % to see if it
helps.

David V.

“Joe S.” [email protected] writes:

If I execute my apps from a command line using this syntax

my_app arg1 arg2 … argx

then ARGV is empty!

.rb exists in my PATHEXT system variable so it should be treated the same as
a .exe. Anyone else encountered this?

This isn’t what I see:

C:\Temp>type abu.rb
p ARGV

C:\Temp>abu what ever you want
[“what”, “ever”, “you”, “want”]

Now, in the registry, the default value for HKEY_CLASSES_ROOT.rb is
“rbFile” and the default value for
HKEY_CLASSES_ROOT\rbFile\Shell\open\command is:
“c:\ruby\bin\ruby.exe” “%1” %*

I suspect that your registry entry is missing the %* bit. Go open up
regedit, find HKEY_CLASSES_ROOT.rb, find that default value (probably
rbFile, but if it isn’t use that value where I say “rbFile”), then
find the default on HKEY_CLASSES_ROOT\rbFile\Shell (probably “open”),
then look at the default on
HKEY_CLASSES_ROOT\rbFile\Shell\open\command and see if that includes
the %* bit. If it doesn’t, add it.

Hi,

At Thu, 17 Aug 2006 15:42:20 +0900,
[email protected] wrote in [ruby-talk:208901]:

IIRC, assoc command built in cmd.exe does it. Try assoc /?.
Sorry, it was ftype.

assoc .rb=rbFile
ftype rbFile=ruby “%1” %*

Hi,

At Thu, 17 Aug 2006 09:47:39 +0900,
Daniel M. wrote in [ruby-talk:208880]:

I suspect that your registry entry is missing the %* bit. Go open up
regedit, find HKEY_CLASSES_ROOT.rb, find that default value (probably
rbFile, but if it isn’t use that value where I say “rbFile”), then
find the default on HKEY_CLASSES_ROOT\rbFile\Shell (probably “open”),
then look at the default on
HKEY_CLASSES_ROOT\rbFile\Shell\open\command and see if that includes
the %* bit. If it doesn’t, add it.

IIRC, assoc command built in cmd.exe does it. Try assoc /?.

On 8/16/06, David V. [email protected] wrote:

The opener for ruby could be set up to run “ruby %1”, where %1 is only the
script file name. I don’t have a Ruby installed on my Windows boot right
now, but poke around the registry looking for what filetype the “.rb”
extension is registered to, and then search for the name of the filetype
to scrounge up what the command string is.

C:> ftype rbFile
rbFile=“C:\Ruby\bin\ruby.exe” “%1” %*

There may be a better choice, but that’s what mine is set to with a
recent install of 1.8.4.

-austin

Thanks to everyone for your input here. My ftype entry (rb_auto_file)
was
missing the %* on the end of it. In the past this must have been
entered by
default when I setup other associations, because I have not run into
this in
the past with other, possibly unmentionable, languages…