Skip Menu |

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

Report information
The Basics
Id: 54184
Status: open
Priority: 0/
Queue: IPC-Cmd

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

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



Subject: ampersand in argument handled incorrectly if IPC::Run is used
perl, v5.10.0 built for i486-linux-gnu-thread-multi IPC::Cmd 0.54 IPC::Run 0.84 Ubuntu 9.04 I've attached the following runner scripts: ipc_cmd_ipc_open3.pl ipc_cmd_ipc_run.pl ipc_cmd_system.pl ipc_run.pl They all do what their names suggest i.e. run a command using IPC::Cmd (with three different options) or IPC::Run. I've also attached a simple command, runnee.pl, which prints a Data::Dumper dump of its arguments. I invoke the runners with the following arguments (note the ampersand in the final argument): foo 1 'bar' "isn't" "http://www.test.com?foo=bar&baz=quux" e.g. ./ipc_cmd_system.pl foo 1 'bar' "isn't" "http://www.test.com?foo=bar&baz=quux" This works fine for IPC::Run, IPC::Cmd using IPC::Open3, and IPC::Cmd using system(), but breaks for IPC::Cmd using IPC::Run. In the latter case, the final argument is not received by the command. chocolateboy
Subject: ipc_cmd_ipc_open3.pl
#!/usr/bin/env perl use strict; use warnings; use feature qw(:5.10); use Data::Dumper; $Data::Dumper::Terse = $Data::Dumper::Indent = 1; use IPC::Cmd qw(run);; say "runner (IPC::Cmd(IPC::Open3)) args: ", Dumper(\@ARGV); $IPC::Cmd::USE_IPC_RUN = 0; $IPC::Cmd::USE_IPC_OPEN3 = 1; $IPC::Cmd::DEBUG = 1; my ($ok, $err) = run( command => [ './runnee.pl', @ARGV ], verbose => 1 ); die "error: $err" unless ($ok);
Subject: runnee.pl
#!/usr/bin/env perl use strict; use warnings; use feature qw(:5.10); use Data::Dumper; $Data::Dumper::Terse = $Data::Dumper::Indent = 1; say "runnee args: ", Dumper(\@ARGV);
Subject: ipc_run.pl
#!/usr/bin/env perl use strict; use warnings; use feature qw(:5.10); use Data::Dumper; $Data::Dumper::Terse = $Data::Dumper::Indent = 1; use IPC::Run qw(run);; say "runner (IPC::Run) args: ", Dumper(\@ARGV); $ENV{IPCRUNDEBUG} = 'basic'; my $ok = run([ './runnee.pl', @ARGV ]); die "error: $?" unless ($ok);
Subject: ipc_cmd_system.pl
#!/usr/bin/env perl use strict; use warnings; use feature qw(:5.10); use Data::Dumper; $Data::Dumper::Terse = $Data::Dumper::Indent = 1; use IPC::Cmd qw(run);; say "runner (IPC::Cmd(system)) args: ", Dumper(\@ARGV); $IPC::Cmd::USE_IPC_RUN = 0; $IPC::Cmd::USE_IPC_OPEN3 = 0; $IPC::Cmd::DEBUG = 1; my ($ok, $err) = run( command => [ './runnee.pl', @ARGV ], verbose => 1 ); die "error: $err" unless ($ok);
Subject: ipc_cmd_ipc_run.pl
#!/usr/bin/env perl use strict; use warnings; use feature qw(:5.10); use Data::Dumper; $Data::Dumper::Terse = $Data::Dumper::Indent = 1; use IPC::Cmd qw(run);; say "runner (IPC::Cmd(IPC::Run)) args: ", Dumper(\@ARGV); $IPC::Cmd::USE_IPC_RUN = 1; $IPC::Cmd::USE_IPC_OPEN3 = 0; $IPC::Cmd::DEBUG = 1; $ENV{IPCRUNDEBUG} = 'basic'; my ($ok, $err) = run( command => [ './runnee.pl', @ARGV ], verbose => 1 ); die "error: $err" unless ($ok);
After further testing, it appears that the problem occurs if any of the characters in SPECIAL_CHARS appear anywhere in any argument i.e. the following are all mishandled by _ipc_run: http://www.test.com?foo=bar|baz http://www.test.com?foo=bar&baz http://www.test.com?foo=bar<baz http://www.test.com?foo=bar>baz Note: treating these characters as "special" is going to break things like: cut -d '|' -f1 e.g. $ ./ipc_cmd_ipc_run.pl cut -d '|' -f1 error: Command '-f1' not found $ ./ipc_cmd_ipc_run.pl config --add-email 'Foo Bar <foobar@test.com>' runnee args: [ 'config', '--add-email' ] chocolateboy