* [PATCH 0/5] some yak shaving
@ 2020-12-27 2:53 5% Eric Wong
2020-12-27 2:53 7% ` [PATCH 1/5] git: qx: avoid extra "local" for scalar context case Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2020-12-27 2:53 UTC (permalink / raw)
To: meta
Some minor things to fix some small annoyances; I needed a break
from other areas of the code.
Eric Wong (5):
git: qx: avoid extra "local" for scalar context case
import: check for git->qx errors, clearer return values
check defined return value for localized slurp errors
ds: simplify EventLoop implementation
ds: flatten + reuse @events, epoll_wait style fixes
lib/PublicInbox/DS.pm | 49 ++++++++--------------------
lib/PublicInbox/DSKQXS.pm | 2 +-
lib/PublicInbox/DSPoll.pm | 3 +-
lib/PublicInbox/Gcf2.pm | 2 +-
lib/PublicInbox/Git.pm | 6 ++--
lib/PublicInbox/Import.pm | 9 +++---
lib/PublicInbox/Inbox.pm | 9 ++----
lib/PublicInbox/Syscall.pm | 66 +++++++++++++++++++++-----------------
script/public-inbox-edit | 3 +-
script/public-inbox-init | 6 +---
script/public-inbox-learn | 3 +-
script/public-inbox-purge | 2 +-
t/ds-poll.t | 28 ++++++++--------
t/epoll.t | 8 ++---
t/git.t | 5 +++
15 files changed, 92 insertions(+), 109 deletions(-)
^ permalink raw reply [relevance 5%]
* [PATCH 1/5] git: qx: avoid extra "local" for scalar context case
2020-12-27 2:53 5% [PATCH 0/5] some yak shaving Eric Wong
@ 2020-12-27 2:53 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-12-27 2:53 UTC (permalink / raw)
To: meta
We can use the ternary operator to avoid an early return, here
---
lib/PublicInbox/Git.pm | 6 ++----
t/git.t | 1 +
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index 08406925..73dc7d3e 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -362,10 +362,8 @@ sub popen {
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 dfd7173a..dcd053c5 100644
--- a/t/git.t
+++ b/t/git.t
@@ -79,6 +79,7 @@ if (1) {
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');
^ permalink raw reply related [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-12-27 2:53 5% [PATCH 0/5] some yak shaving Eric Wong
2020-12-27 2:53 7% ` [PATCH 1/5] git: qx: avoid extra "local" for scalar context case Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).