6

My demo.rb:

puts ARGV.size

ARGV.each do |a|
  puts "Argument: #{a}"
end

The result depends on how we run a script:

> demo.rb foo bar
0

> ruby demo.rb foo bar
2
Argument: foo
Argument: bar

Why this happens? And can some thing be done with this?

EDIT: Thanks to all replies! Here my settings:

>assoc .rb
.rb=rbFile

>ftype rbFile
rbFile="c:\ruby-1.8.6\bin\ruby.exe" "%1" %*

So it looks right.

But I have discovered that

>demo.rb foo bar

starts process with such Command Line:

"C:\ruby-1.8.7\bin\ruby.exe" "c:\demo.rb"

Notice, that .rb associated with 1.8.6, but 1.8.7 is started.

So I guess some thing else is messed up?

4

5 回答 5

8

打开命令窗口:

assoc .rb

是rbFile吗?

ftype rbFile

确保 Ruby.exe 后跟“%1”%*

%* 有时会丢失。

于 2009-08-27T13:56:05.740 回答
3
C:\Temp> ftype | grep 红宝石
rbFile="c:\opt\ruby\bin\ruby.exe" "%1" %*
rbwFile="c:\opt\ruby\bin\rubyw.exe" "%1" %*
于 2009-08-27T13:56:17.673 回答
2

Check the file association. Especially in the advanced settings look at the "Open" action. Make sure that there is a %* on the end of the action.

This question is about powershell, but it is essentially the same question so my answer there should give a little more detail.

于 2009-08-27T13:53:36.413 回答
1

在您的文件类型关联中,听起来参数没有传递给 ruby​​ 解释器。请参阅本节了解关联的外观,并验证您的关联。

于 2009-08-27T13:55:59.047 回答
0

您可以使用Nirsoft的免费软件工具- FileTypesManager - 添加%*其他帖子中提到的缺失。

于 2012-08-01T07:07:31.747 回答