user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: meta@public-inbox.org
Subject: [PATCH 4/5] lei ls-mail-sync: fix handling of non-wildcard filters
Date: Tue,  4 May 2021 00:45:58 -0400	[thread overview]
Message-ID: <20210504044559.12941-5-kyle@kyleam.com> (raw)
In-Reply-To: <20210504044559.12941-1-kyle@kyleam.com>

If lei_ls_mail_sync() is given a filter without any wildcards and
--globoff is unspecified, glob2re() will return undef, resulting in
the final regular expression being undefined.  Add a fallback value.
---

  I'm not sure if this is the cleanest approach; repeating
  qr/\Q$filter\E/ seems ugly.  I considered something closer to what
  lei_ls_external() does, but decided against it because it leads to
  --globoff with no filter showing no output, which I think is
  surprising (even if passing --globoff with no filter doesn't make
  any sense).
  
  This probably deserves a test, but I'm out of time for tonight.  If
  the change looks okay, I'm happy to look into adding a test
  tomorrow.

 lib/PublicInbox/LeiLsMailSync.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/PublicInbox/LeiLsMailSync.pm b/lib/PublicInbox/LeiLsMailSync.pm
index 532ea9b5..06e25a63 100644
--- a/lib/PublicInbox/LeiLsMailSync.pm
+++ b/lib/PublicInbox/LeiLsMailSync.pm
@@ -14,7 +14,7 @@ sub lei_ls_mail_sync {
 	my $opt = $lei->{opt};
 	my $re;
 	$re = defined($filter) ? qr/\Q$filter\E/ : qr/./ if $opt->{globoff};
-	$re //= $lei->glob2re($filter // '*');
+	$re //= $lei->glob2re($filter // '*') // qr/\Q$filter\E/;;
 	my @f = $lms->folders;
 	@f = $opt->{'invert-match'} ? grep(!/$re/, @f) : grep(/$re/, @f);
 	if ($opt->{'local'} && !$opt->{remote}) {
-- 
2.31.1


  parent reply	other threads:[~2021-05-04  4:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-04  4:45 [PATCH 0/5] Minor ls-mail-sync fixes Kyle Meyer
2021-05-04  4:45 ` [PATCH 1/5] lei ls-mail-sync: update reference to ls-sync Kyle Meyer
2021-05-04  4:45 ` [PATCH 2/5] lei ls-mail-sync: drop repeated -z/0 option Kyle Meyer
2021-05-04  4:45 ` [PATCH 3/5] lei ls-mail-sync: accept a filter Kyle Meyer
2021-05-04  4:45 ` Kyle Meyer [this message]
2021-05-04  5:14   ` [PATCH 4/5] lei ls-mail-sync: fix handling of non-wildcard filters Eric Wong
2021-05-04  4:45 ` [PATCH 5/5] lei: add help output for --invert match Kyle Meyer

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: https://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=20210504044559.12941-5-kyle@kyleam.com \
    --to=kyle@kyleam.com \
    --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).