]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
bin/grepc, grepc.1: -A, -B, -C: Add flags for printing context.
authorAlejandro Colomar <alx@kernel.org>
Sat, 4 Nov 2023 21:00:57 +0000 (22:00 +0100)
committerAlejandro Colomar <alx@kernel.org>
Wed, 29 Oct 2025 20:29:20 +0000 (21:29 +0100)
These flags are passed to pcre2grep(1).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
bin/grepc
share/man/man1/grepc.1

index f1e105b4b3881761300ebc75f41ca5bd4499dc95..0123742b6e53b34e47f7457e5a211f0a562b9281 100755 (executable)
--- a/bin/grepc
+++ b/bin/grepc
@@ -2,6 +2,9 @@
 
 
 # Defaults:
+A='';
+B='';
+C='';
 c='no';
 h='-H';
 i='';
@@ -40,8 +43,17 @@ grepc_err()
 
 grepc_parse_cmd()
 {
-       while getopts "chiklt:" opt; do
+       while getopts "A:B:C:chiklt:" opt; do
                case "$opt" in
+               A)
+                       A="-A$OPTARG";
+                       ;;
+               B)
+                       B="-B$OPTARG";
+                       ;;
+               C)
+                       C="-C$OPTARG";
+                       ;;
                c)
                        c='yes';
                        ;;
@@ -236,6 +248,9 @@ grepc_search()
 
        grepc_patterns "$identifier" >"$patterns";
 
+       opts="$opts $A";
+       opts="$opts $B";
+       opts="$opts $C";
        opts="$opts $h";
        opts="$opts $i";
        opts="$opts $l";
index 0e01781c72548a724fe2f22a4588bb5bbf07c7c7..ac124f36af54126a535e86ed63cf42e5c18e8aa9 100644 (file)
@@ -122,6 +122,21 @@ Uses within type definitions
 .RE
 .SH OPTIONS
 .TP
+.BI \-A \~n
+Print
+.I n
+lines of trailing context after a match.
+.TP
+.BI \-B \~n
+Print
+.I n
+lines of leading context before a match.
+.TP
+.BI \-C \~n
+Print
+.I n
+lines of context surrounding a match.
+.TP
 .B \-c
 Surround the matched strings
 with escape sequences to display them in color on the terminal.