summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2023-11-04 22:00:57 +0100
committerAlejandro Colomar <alx@kernel.org>2023-11-05 03:14:06 +0100
commit3a0bcb88b1cd832d3e26cfd7074c5344129f81a4 (patch)
treea94b0a0b04bab6a032a2d306fec6ff0b37341831 /bin
parenta632aa52833e6f47047692a09301b437defef32f (diff)
bin/grepc, grepc.1: -A, -B, -C: Add flags for printing context.
These flags are passed to pcre2grep(1). Signed-off-by: Alejandro Colomar <alx@kernel.org>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/grepc17
1 files changed, 16 insertions, 1 deletions
diff --git a/bin/grepc b/bin/grepc
index f1e105b..0123742 100755
--- 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";