Explicitly set STDOUT to binary mode

This commit is contained in:
pagedown 2022-03-11 15:42:23 +08:00
parent fe8aaca320
commit 39a78f6be3
No known key found for this signature in database
GPG Key ID: E921CF18AC8FF6EB

View File

@ -149,9 +149,9 @@ while n > 0:
}
elif detect_perl; then
read_n_bytes_from_tty() {
command "$perl" -MList::Util=min -e \
'open(my $fh,"</dev/tty"); binmode($fh); my ($n,$buf)=(@ARGV[0],"");'\
'while($n){my $rv=sysread($fh,$buf,min(65536,$n)); die($!) if !defined($rv); die() if !$rv; $n-=$rv; print $buf;}' "$1" 2> /dev/null
command "$perl" -MList::Util=min -e '
open(my $fh,"<","/dev/tty");binmode($fh);binmode(STDOUT);my ($n,$buf)=(@ARGV[0],"");
while($n>0){my $rv=sysread($fh,$buf,min(65536,$n));unless($rv){exit(1);};$n-=$rv;print STDOUT $buf;}' "$1" 2> /dev/null
}
else
read_n_bytes_from_tty() {