# parent class for LeiImport, LeiConvert, LeiIndex
package PublicInbox::LeiInput;
use v5.12;
+use autodie qw(open);
use PublicInbox::DS;
use PublicInbox::Git qw(git_exe);
use PublicInbox::Spawn qw(which popen_rd);
my $mhr = PublicInbox::MHreader->new($dn, $lei->{3});
$mhr->mh_read_one($n, $self->can('input_mh_cb'), $self);
} elsif (-f $input && $ifmt eq 'eml') {
- open my $fh, '<', $input or
- return $lei->fail("open($input): $!");
+ open my $fh, '<', $input; # autodie::open hits caller eval
$self->input_fh($ifmt, $fh, $input, @args);
} elsif (-f _) {
my $m = $lei->{opt}->{'lock'} //
# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict; use v5.10.1; use PublicInbox::TestCommon;
+use autodie qw(open);
use POSIX qw(mkfifo);
use Fcntl qw(SEEK_SET O_RDONLY O_NONBLOCK);
use IO::Uncompress::Gunzip qw(gunzip);
$cat = popen_rd(['cat', $o]);
lei_ok(qw(q m:qp@example.com -o), "mboxrd:$o");
my $buf = do { local $/; <$cat> };
- open my $fh, '<', \$buf or BAIL_OUT $!;
+ open my $fh, '<', \$buf;
PublicInbox::MboxReader->mboxrd($fh, sub {
my ($eml) = @_;
$eml->header_set('Status', 'RO');
BAIL_OUT 'gunzip';
$buf;
} else {
- open my $fh, '+<', $_[0] or BAIL_OUT $!;
+ open my $fh, '+<', $_[0];
do { local $/; <$fh> };
}
};
$write_file->($o, $buf);
lei_ok(qw(q -a -o), "mboxrd:$o", qw(m:testmessage@example.com));
$buf = $read_file->($o);
- open my $fh, '<', \$buf or BAIL_OUT "PerlIO::scalar $!";
+ open my $fh, '<', \$buf;
my %res;
PublicInbox::MboxReader->mboxrd($fh, sub {
my ($eml) = @_;
lei_ok(qw(q -o), "mboxrd:$o", "m:$m", @inc);
# emulate MUA marking mboxrd message as unread
-open my $fh, '<', $o or BAIL_OUT;
+open my $fh, '<', $o;
my $s = do { local $/; <$fh> };
$s =~ s/^Status: RO\n/Status: O\nX-Status: AF\n/sm or
fail "failed to clear R flag in $s";
-open $fh, '>', $o or BAIL_OUT;
+open $fh, '>', $o;
print $fh $s or BAIL_OUT;
close $fh or BAIL_OUT;
lei_ok(qw(q -o), "mboxrd:$o", 'm:bogus', @inc,
\'clobber mbox to import keywords');
lei_ok(qw(q -o), "mboxrd:$o", "m:$m", @inc);
-open $fh, '<', $o or BAIL_OUT;
+open $fh, '<', $o;
$s = do { local $/; <$fh> };
like($s, qr/^Status: O\nX-Status: AF\n/ms,
'seen keyword gone in mbox, answered + flagged set');
lei_ok([qw(import -F eml --stdin)], undef, { 0 => \$in, %$lei_opt });
is($lei_err, '', 'no errors from import');
lei_ok(qw(q -f mboxrd), "m:$m");
-open $fh, '<', \$lei_out or BAIL_OUT $!;
+open $fh, '<', \$lei_out;
my @res;
PublicInbox::MboxReader->mboxrd($fh, sub { push @res, shift });
is($res[0]->header('Status'), 'RO', 'seen kw set');
is($lei_err, '', 'no errors from 2nd import');
lei_ok(qw(q -f mboxrd), "m:$m", 'l:another.example.com');
my @another;
-open $fh, '<', \$lei_out or BAIL_OUT $!;
+open $fh, '<', \$lei_out;
PublicInbox::MboxReader->mboxrd($fh, sub { push @another, shift });
is($another[0]->header('Status'), 'RO', 'seen kw set');
scalar(@p) == 1 or xbail('multiple when 1 expected', \@p);
like($p[0], qr/,PS/, 'passed (Forwarded) flag kept');
lei_ok(qw(q -o), "mboxrd:$o.mboxrd", "m:$m");
- open $fh, '<', "$o.mboxrd" or xbail $!;
+ open $fh, '<', "$o.mboxrd";
my @res;
PublicInbox::MboxReader->mboxrd($fh, sub { push @res, shift });
scalar(@res) == 1 or xbail('multiple when 1 expected', \@res);
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
use v5.10.1;
-use autodie qw(seek);
+use autodie qw(open seek);
use PublicInbox::TestCommon;
use List::Util qw(shuffle);
use PublicInbox::Eml;
my $fmt = shift;
my @order = shuffle(keys %raw);
my $eml2mbox = PublicInbox::LeiToMail->can("eml2$fmt");
- open my $fh, '+>', undef or BAIL_OUT "open: $!";
+ open my $fh, '+>', undef;
for my $k (@order) {
my $eml = PublicInbox::Eml->new($raw{$k});
my $buf = $eml2mbox->($eml);
# chop($no_blank_eom) eq "\n" or BAIL_OUT 'broken LF';
for my $variant (qw(mboxrd mboxo)) {
my @x;
- open my $fh, '<', \$no_blank_eom or BAIL_OUT 'PerlIO::scalar';
+ open my $fh, '<', \$no_blank_eom;
$reader->$variant($fh, sub { push @x, shift });
is_deeply($x[0]->{bdy}, \"body1\n", 'LF preserved in 1st');
is_deeply($x[1]->{bdy}, \"body2\n", 'no LF added in 2nd');
for my $m (qw(mboxrd mboxcl mboxcl2 mboxo)) {
my (@w, @x);
local $SIG{__WARN__} = sub { push @w, @_ };
- open my $fh, '<', \$html or xbail 'PerlIO::scalar';
+ open my $fh, '<', \$html;
PublicInbox::MboxReader->$m($fh, sub {
push @x, $_[0]->as_string
});