We can use the ternary operator to avoid an early return, here
sub qx {
my ($self, @cmd) = @_;
my $fh = $self->popen(@cmd);
- local $/ = "\n";
- return <$fh> if wantarray;
- local $/;
- <$fh>
+ local $/ = wantarray ? "\n" : undef;
+ <$fh>;
}
# check_async and cat_async may trigger the other, so ensure they're
my @ref = $gcf->qx(qw(cat-file blob), $buf);
my $nl = scalar @ref;
ok($nl > 1, "qx returned array length of $nl");
+ is(join('', @ref), $ref, 'qx array and scalar context both work');
$gcf->qx(qw(repack -adq));
ok($gcf->packed_bytes > 0, 'packed size is positive');