Skip to content

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

@mattjacob

Description

@mattjacob

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";
    }
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions