]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: err: avoid uninitialized variable warnings
authorEric Wong <e@80x24.org>
Wed, 3 Feb 2021 08:11:36 +0000 (22:11 -1000)
committerEric Wong <e@80x24.org>
Thu, 4 Feb 2021 01:37:09 +0000 (01:37 +0000)
lib/PublicInbox/LEI.pm

index 9afc90cfaa1067d7a0b852debf8a0bf6575da9ed..9b4d4e0ba7aa2d68909cfe83cec6db4c8bcf9a89 100644 (file)
@@ -308,12 +308,12 @@ sub x_it ($$) {
 sub err ($;@) {
        my $self = shift;
        my $err = $self->{2} // ($self->{pgr} // [])->[2] // *STDERR{GLOB};
-       my $eor = (substr($_[-1], -1, 1) eq "\n" ? () : "\n");
-       print $err @_, $eor and return;
+       my @eor = (substr($_[-1]//'', -1, 1) eq "\n" ? () : ("\n"));
+       print $err @_, @eor and return;
        my $old_err = delete $self->{2};
-       close($old_err) if $! == EPIPE && $old_err;;
+       close($old_err) if $! == EPIPE && $old_err;
        $err = $self->{2} = ($self->{pgr} // [])->[2] // *STDERR{GLOB};
-       print $err @_, $eor or print STDERR @_, $eor;
+       print $err @_, @eor or print STDERR @_, @eor;
 }
 
 sub qerr ($;@) { $_[0]->{opt}->{quiet} or err(shift, @_) }