Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ if ( $^O ne 'MSWin32' ) {
}
}
else {
$PREREQ_PM{'Win32::Process'} = '0.14';
$PREREQ_PM{'Win32API::File'} = '0.0901';
$PREREQ_PM{'Win32::Process'} = '0.14';
$PREREQ_PM{'Win32::ShellQuote'} = 0;
$PREREQ_PM{'Win32API::File'} = '0.0901';
if ( $] >= 5.021006 ) {
$PREREQ_PM{'Win32API::File'} = '0.1203';
}
Expand Down
12 changes: 7 additions & 5 deletions lib/IPC/Run/Win32Helper.pm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ require POSIX;

use Text::ParseWords;
use Win32::Process;
use Win32::ShellQuote ();
use IPC::Run::Debug;
use Win32API::File qw(
FdGetOsFHandle
Expand Down Expand Up @@ -323,6 +324,11 @@ trying to be a little cross-platform here. The only difference is
that "\" is *not* treated as an escape except when it precedes
punctuation, since it's used all over the place in DOS path specs.

TODO: strip caret escapes?

TODO: use
https://docs.microsoft.com/en-us/cpp/cpp/main-function-command-line-args#parsing-c-command-line-arguments

TODO: globbing? probably not (it's unDOSish).

TODO: shebang emulation? Probably, but perhaps that should be part
Expand Down Expand Up @@ -442,11 +448,7 @@ sub win32_spawn {
}

my $process;
my $cmd_line = join " ", map {
( my $s = $_ ) =~ s/"/"""/g;
$s = qq{"$s"} if /[\"\s]|^$/;
$s;
} @$cmd;
my $cmd_line = Win32::ShellQuote::quote_native(@$cmd);

_debug "cmd line: ", $cmd_line
if _debugging;
Expand Down
27 changes: 26 additions & 1 deletion t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ sub get_warnings {
select STDERR;
select STDOUT;

use Test::More tests => 268;
use Test::More tests => 272;
use IPC::Run::Debug qw( _map_fds );
use IPC::Run qw( :filters :filter_imp start );

Expand Down Expand Up @@ -210,6 +210,31 @@ is $? >> 8, 42;
is( _map_fds, $fd_map );
$fd_map = _map_fds;

##
## Arguments bearing most bytes, excluding NUL (unsupported) and BEL (noisy and
## not otherwise special). Arguments bearing special sequences of bytes.
##
{
local $ENV{PERL_UNICODE};
delete $ENV{PERL_UNICODE};

my @bytes = map { $_ == 7 ? () : pack( 'C', $_ ); } 1 .. 0xFF;
$r = run(
[ $perl, '-e', 'binmode STDOUT; print join "\0", @ARGV', @bytes ],
'>', \$out
);
eok( $out, join "\0", @bytes );

my $sequences = qq{\\"\\az\\\\"\\\\\\};
foreach my $payload ( join( '', @bytes ), $sequences, "$sequences\n" ) {
$r = run(
[ $perl, '-e', 'binmode STDOUT; print @ARGV', $payload ],
'>', \$out
);
eok( $out, $payload );
}
}

##
## A function
##
Expand Down
3 changes: 2 additions & 1 deletion t/win32_compile.t
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ BEGIN {
plan( skip_all => "android does not support getprotobyname()" );
}

$INC{$_} = 1 for qw( Win32/Process.pm Win32API/File.pm );
$INC{$_} = 1 for qw(
Win32/Process.pm Win32/ShellQuote.pm Win32API/File.pm );

package Win32API::File;

Expand Down