diff --git a/lib/Core/Pgrep.pm b/lib/Core/Pgrep.pm index c1e918d8a65346aaa13ce8d7157f95be803ac90c..5de40db815618d5970c410c5f5c870f6fa1099b2 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));