From 3dde6fa1268e2f86f10f26b7d427598e582aed2a Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 20 Jan 2021 14:04:43 +0900 Subject: lei: allow more mbox inode types 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 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'lib') 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 { -- cgit v1.2.3-24-ge0c7