p - Don't ask for command when finished, exit directly

This commit is contained in:
Adolfo Perez Alvarez 2024-07-05 17:00:22 +02:00
parent bd5a149cc0
commit 61efff731f

4
p
View File

@ -27,19 +27,21 @@ sub printfile {
print; print;
&evalcmd unless ++$lines % $pagesize; &evalcmd unless ++$lines % $pagesize;
} }
&evalcmd;
} }
unshift(@ARGV, '-') unless @ARGV; unshift(@ARGV, '-') unless @ARGV;
my $n = $#ARGV;
for (@ARGV) { for (@ARGV) {
if (/^-$/) { if (/^-$/) {
&printfile(\*STDIN); &printfile(\*STDIN);
&evalcmd if $n--;
} elsif (/^-(\d+)$/) { } elsif (/^-(\d+)$/) {
$pagesize = $1; $pagesize = $1;
} else { } else {
open(my $fh, '<', $_) or die "$0: Cannot open $_ for reading: $!"; open(my $fh, '<', $_) or die "$0: Cannot open $_ for reading: $!";
&printfile($fh); &printfile($fh);
&evalcmd if $n--;
close($fh); close($fh);
} }
} }