shorthand -f+ for first number (+0)
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 20 Nov 2022 17:50:45 +0000 (18:50 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 21 Nov 2022 15:24:42 +0000 (16:24 +0100)
barcat

diff --git a/barcat b/barcat
index 5181143fe9bdd92d1544dc49b69f07e52ddaa754..d8deee4b6834d3893ce71e706feba5e2f522d449 100755 (executable)
--- a/barcat
+++ b/barcat
@@ -20,7 +20,9 @@ GetOptions(\%opt,
                eval {
                        local $_ = $_[1];
                        s/\A[0-9]+\z/(?:\\S*\\h+){$_}\\K/;
-                       s/\A[+]([0-9]*)\z/(?:\\d+\\D+\\b){$1}\\K \\s* (?=\\d)/;
+                       s{\A[+]([0-9]*)\z}{
+                               (!!$1 && '(?:\d+\D+\b){'.$1.'}\K') . '\s* (?=\d)'
+                       }e;
                        $opt{anchor} = qr/$_/;
                } or die $@ =~ s/(?:\ at\ \N+)?\Z/ for option $_[0]/r;
        },
@@ -605,7 +607,7 @@ Compare file sizes (with human-readable numbers):
 
 Same from formatted results, selecting the first numeric value:
 
-    tree -s --noreport | barcat -H -f+0
+    tree -s --noreport | barcat -H -f+
 
 Memory usage of user processes with long names truncated: