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).
This commit is contained in:
13
clatd
13
clatd
@@ -73,18 +73,17 @@ sub err {
|
|||||||
#
|
#
|
||||||
sub cmd {
|
sub cmd {
|
||||||
my $msgsub = shift;
|
my $msgsub = shift;
|
||||||
my $command = shift;
|
my @cmd = @_;
|
||||||
my @cmdline = @_;
|
|
||||||
|
|
||||||
d("cmd($command @cmdline)");
|
d("cmd(@cmd)");
|
||||||
|
|
||||||
if(system($command, @cmdline)) {
|
if(system(@cmd)) {
|
||||||
if($? == -1) {
|
if($? == -1) {
|
||||||
&{$msgsub}("cmd($command @cmdline) failed to execute");
|
&{$msgsub}("cmd(@cmd) failed to execute");
|
||||||
} elsif($? & 127) {
|
} elsif($? & 127) {
|
||||||
&{$msgsub}("cmd($command @cmdline) died with signal ", ($? & 127));
|
&{$msgsub}("cmd(@cmd) died with signal ", ($? & 127));
|
||||||
} else {
|
} else {
|
||||||
&{$msgsub}("cmd($command @cmdline) returned ", ($? >> 127));
|
&{$msgsub}("cmd(@cmd) returned ", ($? >> 127));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $?;
|
return $?;
|
||||||
|
|||||||
Reference in New Issue
Block a user