pjf / ipc-system-simple

Perl module to make running system commands and capturing errors as simple as possible.
http://search.cpan.org/perldoc?IPC::System::Simple
Other
19 stars 20 forks source link

Multi-argument run() fails on Windows when first parameter is a full path that contains spaces #22

Open mattjacob opened 7 years ago

mattjacob commented 7 years ago

Tests 1 and 2 below fail, but 3 and 4 work. The third one isn't great, because it makes me responsible for properly quoting the entire command. The fourth one isn't great either, because the thing we want to run might not be in the PATH.

use strict;
use warnings;

use Data::Dumper;
use IPC::System::Simple qw(run);

my @tests = (
    ['C:\Program Files\TortoiseSVN\bin\svn.exe', 'help'],
    ['"C:\Program Files\TortoiseSVN\bin\svn.exe"', 'help'],
    ['"C:\Program Files\TortoiseSVN\bin\svn.exe" help'],
    ['svn', 'help'],
);

for (@tests) {
    print "Running with run(): ", Dumper($_), "\n";

    eval {
        run(@$_);
    };

    if ($@) {
        print "Error: [$@]\n";
    }
}
jkeenan commented 4 years ago

I believe that this issue may be resolved in IPC-System-Simple version 1.30, just released to CPAN. Can you confirm?

Thank you very much. Jim Keenan

mattjacob commented 4 years ago

Sorry, I can’t test because l no longer have access to a Windows machine.

mrudat commented 1 year ago

I ran into this error, and after upgrading to the latest version, it appears to work as expected.

Using git instead of svn, test cases 1, 3 and 4 pass.

Test case 2 fails (as expected), presumably due to being both manually and automatically quoted.