From 61efff731f352e52c5173ff676988c61c6079420 Mon Sep 17 00:00:00 2001 From: Adolfo Perez Alvarez Date: Fri, 5 Jul 2024 17:00:22 +0200 Subject: [PATCH] p - Don't ask for command when finished, exit directly --- p | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/p b/p index 6ce6fb3..71826ad 100755 --- a/p +++ b/p @@ -27,19 +27,21 @@ sub printfile { print; &evalcmd unless ++$lines % $pagesize; } - &evalcmd; } unshift(@ARGV, '-') unless @ARGV; +my $n = $#ARGV; for (@ARGV) { if (/^-$/) { &printfile(\*STDIN); + &evalcmd if $n--; } elsif (/^-(\d+)$/) { $pagesize = $1; } else { open(my $fh, '<', $_) or die "$0: Cannot open $_ for reading: $!"; &printfile($fh); + &evalcmd if $n--; close($fh); } }