From 5e2297903aadc86e5e130140791a5328c9c911b6 Mon Sep 17 00:00:00 2001 From: Tore Anderson Date: Fri, 23 Oct 2015 11:49:51 +0200 Subject: [PATCH] Improve handing of single-scalar calls to cmd() Just pass the entire supplied command line, be it a single scalar or an array, to system(). It'll do the right thing with it. This gets rid of a spurious trailing space in debugging output when cmd() was called with a single scalar as the command argument (leaving @cmdline undefined). --- clatd | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/clatd b/clatd index d58b629..1a3778a 100755 --- a/clatd +++ b/clatd @@ -73,18 +73,17 @@ sub err { # sub cmd { my $msgsub = shift; - my $command = shift; - my @cmdline = @_; + my @cmd = @_; - d("cmd($command @cmdline)"); + d("cmd(@cmd)"); - if(system($command, @cmdline)) { + if(system(@cmd)) { if($? == -1) { - &{$msgsub}("cmd($command @cmdline) failed to execute"); + &{$msgsub}("cmd(@cmd) failed to execute"); } elsif($? & 127) { - &{$msgsub}("cmd($command @cmdline) died with signal ", ($? & 127)); + &{$msgsub}("cmd(@cmd) died with signal ", ($? & 127)); } else { - &{$msgsub}("cmd($command @cmdline) returned ", ($? >> 127)); + &{$msgsub}("cmd(@cmd) returned ", ($? >> 127)); } } return $?;