user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 07/10] config: use defined-or (//) in a few places
Date: Tue,  1 Sep 2020 01:15:04 +0000	[thread overview]
Message-ID: <20200901011507.1643-8-e@80x24.org> (raw)
In-Reply-To: <20200901011507.1643-1-e@80x24.org>

Just some golfing to reduce scrolling and hopefully readability.
---
 lib/PublicInbox/Config.pm | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index f9184bd2..ae9ad8de 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -19,7 +19,7 @@ sub _array ($) { ref($_[0]) eq 'ARRAY' ? $_[0] : [ $_[0] ] }
 # if keys may be multi-value, the value is an array ref containing all values
 sub new {
 	my ($class, $file) = @_;
-	$file = default_file() unless defined($file);
+	$file //= default_file();
 	my $self;
 	if (ref($file) eq 'SCALAR') { # used by some tests
 		open my $fh, '<', $file or die;  # PerlIO::scalar
@@ -136,9 +136,7 @@ sub limiter {
 sub config_dir { $ENV{PI_DIR} // "$ENV{HOME}/.public-inbox" }
 
 sub default_file {
-	my $f = $ENV{PI_CONFIG};
-	return $f if defined $f;
-	config_dir() . '/config';
+	$ENV{PI_CONFIG} // (config_dir() . '/config');
 }
 
 sub config_fh_parse ($$$) {

  parent reply	other threads:[~2020-09-01  1:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-01  1:14 [PATCH 00/10] some usability tweaks Eric Wong
2020-09-01  1:14 ` [PATCH 01/10] script/*: set executable bit on -learn and -imapd Eric Wong
2020-09-01  1:14 ` [PATCH 02/10] admin: improve minimum version text Eric Wong
2020-09-01  1:15 ` [PATCH 03/10] edit+purge: support `--help' and `-h' like other commands Eric Wong
2020-09-01  1:15 ` [PATCH 04/10] script/*: fold $usage into $help, support `-h' instead of -? Eric Wong
2020-09-01  1:15 ` [PATCH 05/10] daemon: support --help/-h in -httpd/imapd/nntpd Eric Wong
2020-09-01  1:15 ` [PATCH 06/10] mda+learn: add --help / -h support Eric Wong
2020-09-01  1:15 ` Eric Wong [this message]
2020-09-01  1:15 ` [PATCH 08/10] watch: add --help/-h support Eric Wong
2020-09-01  1:15 ` [PATCH 09/10] doc: remove B<> (bold) markup from the remaining POD Eric Wong
2020-09-01  1:15 ` [PATCH 10/10] init+convert: create non-existing directory hierarchies Eric Wong

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

  List information: http://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200901011507.1643-8-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.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.
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).