From 2c62767bb9d2621d30a9c9e625b84610aa0e46ca Mon Sep 17 00:00:00 2001 From: Graham Knop <gknop@omniti.com> Date: Wed, 14 Dec 2011 15:02:39 -0500 Subject: [PATCH] fix argument handling in Pgrep --- lib/Core/Pgrep.pm | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/Core/Pgrep.pm b/lib/Core/Pgrep.pm index c1e918d..5de40db 100644 --- a/lib/Core/Pgrep.pm +++ b/lib/Core/Pgrep.pm @@ -73,28 +73,22 @@ sub handler { my $pgrep_path = $config->{pgrep_path} || 'pgrep'; my $full = $config->{full} ? "f" : ""; - my $args; + my @args; my $count; my @count; if ( $^O eq "solaris" ) { my $zonename = `zonename`; chomp $zonename; - $args .= "-z $zonename "; + push @args, '-z', $zonename; } if ( $full ) { - $args .= "-f"; + push @args, '-f'; } - # run_command acts oddly if $args is empty. pgrep throws an error. - if ( $args ) { - @count = split(/\n/, (run_command("$pgrep_path $args \'$config->{pattern}\'")) ); - } - else { - @count = split(/\n/, (run_command("$pgrep_path", $config->{pattern})) ); - } + @count = split(/\n/, (run_command($pgrep_path, @args, $config->{pattern})) ); $count = scalar(@count); die "Unable to run pgrep command\n" if (!defined($count)); -- GitLab