=begin
How is that a bug ? If ping is surrounded by quotes, ruby will look for an executable named "ping" with the quotes around. If ruby starts to magically remove these quotes, I'm not sure it will bring other unwanted side-effect. Buy maybe I missed something. Did it work in 1.8.7 maybe ?
=end
=begin
Right, the case became more obvious when we're running commands whose path contains spaces.
In 1.8.7 IO.popen only support cmd_string, not cmd_array, anyway, the respective form IO.popen '"ping" -n 3 localhost' works, and that works in ruby 1.9.2 too.
=end
Right, the case became more obvious when we're running commands whose path contains spaces.
In 1.8.7 IO.popen only support cmd_string, not cmd_array, anyway, the respective form IO.popen '"ping" -n 3 localhost' works, and that works in ruby 1.9.2 too.
I agree that the difference between the string form and the array
form certainly cofuses us.
But it's the spec of IO.popen.
We must quote the arguments (including command) which contain spaces
at the string form, and must not quote the arguments in any cases
at the array form.
=begin
Absolutely agree to Usaku: the whole point of the Array variant of IO.popen is to not need to quote strings. Quoting in the string form is only needed for the implementation to be able to rip arguments properly apart in light of spaces in argument names (any argument, not only the command path!). Quoting is just a crutch. Since that is not needed in the array variant arguments muss be used unchanged (modulo encoding adjustment maybe).
=end