Skip to content

Commit

Permalink
Checking if can open.
Browse files Browse the repository at this point in the history
  • Loading branch information
Timofey Potapov committed Jul 20, 2024
1 parent 56c7cd2 commit f71be14
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/e.pm
Original file line number Diff line number Diff line change
Expand Up @@ -753,12 +753,14 @@ sub import {
# Needs to be explicitly closed to avoid
# issues with next say() if still closed:
# "say() on closed filehandle STDOUT"
if ( !-t STDOUT and -w "/dev/tty" ) {
open my $tty, ">", "/dev/tty" or die $!;
caller->can( "utf8" )->( $tty ); # Method now in caller.
my $prefix = caller->can( "dye" )->( "no-stdout: ", "CYAN" );
CORE::say( $tty $prefix, @args );
close $tty;
if ( !-t STDOUT ) {
if ( open my $tty, ">", "/dev/tty" ) {
caller->can( "utf8" )->( $tty ); # Method now in caller.
my $prefix =
caller->can( "dye" )->( "no-stdout: ", "CYAN" );
CORE::say( $tty $prefix, @args );
close $tty;
}
}
},

Expand Down

0 comments on commit f71be14

Please sign in to comment.