From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] spawn: rely on auto-vivification for options
Date: Tue, 26 Sep 2023 10:01:08 +0000 [thread overview]
Message-ID: <20230926100108.442359-1-e@80x24.org> (raw)
While we're at it, we can also avoid the fileno call
since spawn() can take IO/GLOB references nowadays.
---
lib/PublicInbox/Spawn.pm | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/lib/PublicInbox/Spawn.pm b/lib/PublicInbox/Spawn.pm
index 38619fc2..c18c2388 100644
--- a/lib/PublicInbox/Spawn.pm
+++ b/lib/PublicInbox/Spawn.pm
@@ -332,7 +332,6 @@ sub spawn ($;$$) {
my ($cmd, $env, $opts) = @_;
my $f = which($cmd->[0]) // die "$cmd->[0]: command not found\n";
my @env;
- $opts ||= {};
my %env = (%ENV, $env ? %$env : ());
while (my ($k, $v) = each %env) {
push @env, "$k=$v" if defined($v);
@@ -367,8 +366,7 @@ sub spawn ($;$$) {
sub popen_rd {
my ($cmd, $env, $opt) = @_;
pipe(my ($r, $w)) or die "pipe: $!\n";
- $opt ||= {};
- $opt->{1} = fileno($w);
+ local $opt->{1} = $w;
my $pid = spawn($cmd, $env, $opt);
return ($r, $pid) if wantarray;
my $s = gensym;
reply other threads:[~2023-09-26 10:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230926100108.442359-1-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).