Skip Menu |

This queue is for tickets about the IPC-Cmd CPAN distribution.

Report information
The Basics
Id: 29723
Status: resolved
Priority: 0/
Queue: IPC-Cmd

People
Owner: Nobody in particular
Requestors: karman [...] cpan.org
SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.36
Fixed in: (no value)



Subject: Array ref form of run(command => ...)
I think the array ref form of run(command => ...) should be removed or implemented differently. For now, if I understand the docs and source of IPC::Cmd correctly, writing run(command => ['a','b','c']) is the same as writing run(command => 'a b c'). The list/array form, as it exists in system() or IPC::Run however, makes sure that shell metacharacters are protected. Especially it does not seem to be possible to call commands with spaces in it with IPC::Cmd, even if using the array form. Regards, Slaven
Subject: escape quoted shell commands
As reported in ticket #29352, the IPC::Run run() call does not escape whitespace in commands. This patch fixes the issue. --- /home/msi/pek/perl/lib/perl5/site_perl/5.8.8/IPC/Cmd.pm 2006-11-24 07:53:57.000000000 -0600 +++ lib/IPC/Cmd.pm 2007-10-02 15:01:27.038158000 -0500 @@ -28,6 +28,7 @@ use Params::Check qw[check]; use Module::Load::Conditional qw[can_load]; use Locale::Maketext::Simple Style => 'gettext'; +use Text::ParseWords; =pod @@ -515,7 +516,8 @@ @command = map { if( /([<>|&])/ ) { $special_chars .= $1; $_; } else { - [ split / +/ ] +# [ split / +/ ] + [ map { m/\ / ? qq{'$_'} : $_ } shellwords($cmd) ] } } split( /\s*([<>|&])\s*/, $cmd ); }
On Tue Oct 02 16:14:31 2007, KARMAN wrote: Show quoted text
> As reported in ticket #29352, the IPC::Run run() call does not escape > whitespace in commands. This patch fixes the issue. > > --- /home/msi/pek/perl/lib/perl5/site_perl/5.8.8/IPC/Cmd.pm > 2006-11-24 07:53:57.000000000 -0600 > +++ lib/IPC/Cmd.pm 2007-10-02 15:01:27.038158000 -0500 > @@ -28,6 +28,7 @@ > use Params::Check qw[check]; > use Module::Load::Conditional qw[can_load]; > use Locale::Maketext::Simple Style => 'gettext'; > +use Text::ParseWords; > > =pod > > @@ -515,7 +516,8 @@ > @command = map { if( /([<>|&])/ ) { > $special_chars .= $1; $_; > } else { > - [ split / +/ ] > +# [ split / +/ ] > + [ map { m/\ / ? qq{'$_'} : $_ } > shellwords($cmd) ] > } > } split( /\s*([<>|&])\s*/, $cmd ); > }
Thanks, applied! Test cases for arguments with spaces in their path have been added to ensure there is no regression.