]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
bin/grepc: srcfix (Remove grepc_search() and main())
authorAlejandro Colomar <alx@kernel.org>
Sun, 5 Nov 2023 15:29:23 +0000 (16:29 +0100)
committerAlejandro Colomar <alx@kernel.org>
Wed, 29 Oct 2025 20:29:24 +0000 (21:29 +0100)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
bin/grepc

index 469b69de7f995d6d8adcfa1ba4c3a535a943dc8d..0bf900cf685643950de52da203a0376f67d8c7a4 100755 (executable)
--- a/bin/grepc
+++ b/bin/grepc
@@ -105,8 +105,6 @@ test $# -lt 1 && grepc_err "Missing identifier.";
 identifier=$1;
 shift;
 
-files=$*;
-
 if [ "$t" = 'no' ]; then
        t_e='yes';
        t_fp='yes';
@@ -177,46 +175,34 @@ patterns="$(mktemp -t grepc.patterns.XXXXXX)";
 ) >"$patterns";
 
 
-grepc_search()
-{
-       local opts='';
-
-       opts="$opts $A";
-       opts="$opts $B";
-       opts="$opts $C";
-       opts="$opts $c";
-       opts="$opts $h";
-       opts="$opts $i";
-       opts="$opts $l";
-       opts="$opts -M";
-       opts="$opts $n";
-
-       if test -z "$files"; then
-               pcre2grep $opts -f "$patterns";
-       else
-               find $files -type f \
-               | if test -z "$c"; then
-                       xargs grep -${i}lPI -- "$identifier";
-               else
-                       cat;
-               fi \
-               | xargs pcre2grep $opts -f "$patterns";
-       fi;
-}
-
-
-main()
-{
-       grepc_search \
-       | sed -E -f <(test "$k" = 'no'  && echo 's/^[^: ]+:[0-9]+:/\n\n&\n/') \
-       | perl -pe "$(test "$r" = 'yes' && echo 's/('"$identifier"')/\033[32m\1\033[0m/' || echo 's///')" \
-       | if [ -n "$l" ]; then
-               sort \
-               | uniq;
+opts='';
+opts="$opts $A";
+opts="$opts $B";
+opts="$opts $C";
+opts="$opts $c";
+opts="$opts $h";
+opts="$opts $i";
+opts="$opts $l";
+opts="$opts -M";
+opts="$opts $n";
+
+
+if test -z "$*"; then
+       pcre2grep $opts -f "$patterns";
+else
+       find "$@" -type f \
+       | if test -z "$c"; then
+               xargs grep -${i}lPI -- "$identifier";
        else
                cat;
-       fi;
-}
-
-
-main;
+       fi \
+       | xargs pcre2grep $opts -f "$patterns";
+fi \
+| sed -E -f <(test "$k" = 'no'  && echo 's/^[^: ]+:[0-9]+:/\n\n&\n/') \
+| perl -pe "$(test "$r" = 'yes' && echo 's/('"$identifier"')/\033[32m\1\033[0m/' || echo 's///')" \
+| if [ -n "$l" ]; then
+       sort \
+       | uniq;
+else
+       cat;
+fi;