]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
bin/grepc, grepc.1: Always enable recursive mode; remove -r
authorAlejandro Colomar <alx@kernel.org>
Sat, 4 Nov 2023 19:45:11 +0000 (20:45 +0100)
committerAlejandro Colomar <alx@kernel.org>
Wed, 29 Oct 2025 20:29:18 +0000 (21:29 +0100)
The non-recursive behavior is so slow that it's quite useless.  It is
only useful when reading from standard input, but for several files it's
useless.  Make '-r' the default when any files are specified, and remove
the flag (since now it's always enabled).  This happens to bring back a
behavior close to what we had before
2fb22befdfb9 ("Don't find files recursively").

Non-seekable files can still be read, if redirected to standard input.

Update the example from the manual page to reflect current usage.

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

index 6d05b25a44fe7b99f6382724092a16ace73524ad..46919fa984ea578fbe6fba51bf50ffbe325f1077 100755 (executable)
--- a/bin/grepc
+++ b/bin/grepc
@@ -5,7 +5,6 @@
 iflag='';
 lflag='';
 kflag='no';
-rflag='no';
 tflag='no';
 t_e='no';
 t_fp='no';
@@ -39,7 +38,7 @@ grepc_err()
 
 grepc_parse_cmd()
 {
-       while getopts "chiklrt:" opt; do
+       while getopts "chiklt:" opt; do
                case "$opt" in
                c)
                        cflag='yes';
@@ -58,9 +57,6 @@ grepc_parse_cmd()
                        lflag='l';
                        kflag='yes';
                        ;;
-               r)
-                       rflag='yes';
-                       ;;
                t)
                        case "$OPTARG" in
                        e)
@@ -238,8 +234,8 @@ grepc_search()
 
        grepc_patterns "$identifier" >"$p";
 
-       if test "$rflag" = 'no'; then
-               pcre2grep -${iflag}${lflag}HMn -f "$p" $files;
+       if test -z "$files"; then
+               pcre2grep -${iflag}${lflag}HMn -f "$p";
        else
                find $files -type f \
                | xargs grep -${iflag}lPI -- "$identifier" \
index eb79522055a4a3b00322ac4815e11573398b657b..176aaa604e9939f7fca43637b35a0aa93048f618 100644 (file)
@@ -21,8 +21,11 @@ and word boundaries are implicitly added to it in most cases.
 If no
 .I file
 is given,
-nonrecursive searches read standard input,
-and recursive searches examine the working directory.
+this program reads standard input.
+Otherwise,
+it reads all files specified,
+and searches under any specified directories, recursively,
+without following symbolic links.
 .SS Types of code
 This program can search for several types of code.
 The following arguments can be passed to the
@@ -144,14 +147,6 @@ instead print the name of each input file
 from which output would normally have been printed.
 Each file is only printed once.
 .TP
-.B \-r
-Recursive search.
-If an input file is a directory,
-read all files under such directory, recursively,
-without following symbolic links.
-This is useful even if specific files are specified in the command line
-as it enables certain optimizations that cannot be enabled in filter mode.
-.TP
 .BI \-t " type"
 Restrict the search to a specific
 .I type
@@ -161,15 +156,21 @@ to search for various types of code.
 Default:
 .BR "e f m t" .
 .SH CAVEATS
+.SS Crashes
 In some cases,
 internal calls to
 .MR pcre2grep 1
 may fail after consuming too much resources.
 To solve that,
 restrict the "types of code" of your search.
+.SS Seekable files
+Files specified in the command line
+must be seekable and able to be opened twice.
+If you need to read a non-seekable file,
+redirect it to the standard input.
 .SH EXAMPLES
 .EX
-.RB \(ti/src/nginx/unit$ " grepc nxt_sprintf;"
+.RB \(ti/src/nginx/unit$ " grepc nxt_sprintf .;"
 \&
 \&
 \&./src/nxt_sprintf.h:15: