From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 130271F934 for ; Wed, 20 Jan 2021 05:04:50 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/7] lei: allow more mbox inode types Date: Wed, 20 Jan 2021 14:04:43 +0900 Message-Id: <20210120050449.71330-2-e@80x24.org> In-Reply-To: <20210119093435.17955-1-e@80x24.org> References: <20210119093435.17955-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We may attempt to write an mbox to any terminal, block, or character device, not just regular files and FIFOs/pipes. The only thing that is known to not work is a directory. Sockets may be possible with some OSes (e.g. Plan 9) or filesystems. This fixes t/lei.t on FreeBSD 11.x --- lib/PublicInbox/LeiOverview.pm | 6 ++---- lib/PublicInbox/LeiToMail.pm | 4 ++-- t/lei.t | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/PublicInbox/LeiOverview.pm b/lib/PublicInbox/LeiOverview.pm index dcc3088b..cab2b055 100644 --- a/lib/PublicInbox/LeiOverview.pm +++ b/lib/PublicInbox/LeiOverview.pm @@ -42,12 +42,10 @@ sub detect_fmt ($$) { my ($lei, $dst) = @_; if ($dst =~ m!\A([:/]+://)!) { $lei->fail("$1 support not implemented, yet\n"); - } elsif (!-e $dst) { - 'maildir'; # the default + } elsif (!-e $dst || -d _) { + 'maildir'; # the default TODO: MH? } elsif (-f _ || -p _) { $lei->fail("unable to determine mbox family of $dst\n"); - } elsif (-d _) { # TODO: MH? - 'maildir'; } else { $lei->fail("unable to determine format of $dst\n"); } diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm index 49b5c8ab..9d9b5748 100644 --- a/lib/PublicInbox/LeiToMail.pm +++ b/lib/PublicInbox/LeiToMail.pm @@ -343,8 +343,8 @@ sub new { "$dst exists and is not a directory\n"; $lei->{ovv}->{dst} = $dst .= '/' if substr($dst, -1) ne '/'; } elsif (substr($fmt, 0, 4) eq 'mbox') { - -e $dst && !-f _ && !-p _ and die - "$dst exists and is not a regular file\n"; + (-d $dst || (-e _ && !-w _)) and die + "$dst exists and is not a writable file\n"; $self->can("eml2$fmt") or die "bad mbox --format=$fmt\n"; $self->{base_type} = 'mbox'; } else { diff --git a/t/lei.t b/t/lei.t index 64cb5f0e..d49dc01a 100644 --- a/t/lei.t +++ b/t/lei.t @@ -187,7 +187,7 @@ my $test_external = sub { is($? >> 8, 1, 'errored out with exit 1'); ok(!$lei->(qw(q s:prefix -f mboxcl2 -o), $home), 'bad mbox'); - like($err, qr!\Q$home\E exists and is not a regular file!, + like($err, qr!\Q$home\E exists and is not a writable file!, 'error shown'); is($? >> 8, 1, 'errored out with exit 1');