lib/PublicInbox/Git.pm | 6 ++---- t/git.t | 1 + diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 084069259110d26e8b043822c0c22ecc4a8a81d7..73dc7d3e5d99feae413f92226cde9e4d77b29b3b 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -362,10 +362,8 @@ 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 diff --git a/t/git.t b/t/git.t index dfd7173a432c78dd9072a9530be7e1695b4ee20d..dcd053c569429efc5a91a86857ee932ee938da82 100644 --- a/t/git.t +++ b/t/git.t @@ -79,6 +79,7 @@ my $ref = $gcf->qx(qw(cat-file blob), $buf); 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');