我正在尝试产生这样的过程
# name I get from network (I'm using webrick)
Process.spawn(name)
然而我最终得到了
ArgumentError: wrong first argument
但这有点奇怪。当我使用binding.pry
在之前突破时
Process.spawn
致电,这就是我得到的:
> name
=> "notepad.exe"
> name == "notepad.exe"
=> true
> Process.spawn(name)
ArgumentError: wrong first argument
from (pry):23: in `spawn`
> Process.spawn("notepad.exe")
=> 728
> Process.spawn(name.to_s)
=> 1416
所以我刚刚确认name
等于"notepad.exe"
和Process.spawn
使用name
调用时失败,使用"notepad.exe"
调用时失败。它
使用name.to_s
调用时也有效。有人可以解释一下会发生什么
上?
name
和"notepad.exe"
都有UTF-8
个编码(通过name.encoding
验证)
并且name
或name.to_s
都不是tainted?
。
我看了source code 但不知道发生了什么。
谢谢。
答案 0 :(得分:2)
问题在于WEBrick::HTTPUtils::FormData
定义了#to_ary
。所以我将使用name.to_s
解决这个问题。