Subject: | Commands containing spaces aren't fully supported? |
I've found that unless I use the one-argument form of capture and supply my own wrapping
quotation marks, commands containing spaces aren't handled the way I expected.
# BAD: program (R) is actually run, but R issues an annoying warning
# that 'Files\R\R-2.10.0\bin\R.exe' is being passed to it as an argument.
use IPC::System::Simple qw/capture/;
print capture("C:\\Program Files\\R\\R-2.10.0\\bin\\R.exe", "-e", "1");
# BAD: wrapping the command argument in quotation marks doesn't work;
# yields the error "failed to start: The filename, directory name, or volume label syntax
# is incorrect".
use IPC::System::Simple qw/capture/;
print capture('"C:\\Program Files\\R\\R-2.10.0\\bin\\R.exe"', "-e", "1");
# GOOD: single-argument form where I build a command-line manually works
use IPC::System::Simple qw/capture/;
print capture('"C:\\Program Files\\R\\R-2.10.0\\bin\\R.exe" -e 1');
Naively, I expected that commands and arguments would be wrapped in quotation marks
automatically as required when specified separately.
In any case, I think it would be good if this were to be documented.