]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
bin/grepc: Compact code
authorAlejandro Colomar <alx@kernel.org>
Fri, 3 Nov 2023 17:23:44 +0000 (18:23 +0100)
committerAlejandro Colomar <alx@kernel.org>
Wed, 29 Oct 2025 20:29:17 +0000 (21:29 +0100)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
bin/grepc

index 1a7b5191d02ddff6123f8f631588b99fee38182d..6d70f99bc2b3e81b5bef38f25760732aa6c2a549 100755 (executable)
--- a/bin/grepc
+++ b/bin/grepc
@@ -237,16 +237,8 @@ grepc_patterns()
 grepc_search()
 {
        pcre2grep -${iflag}${lflag}HMn --label="$file" -f <(grepc_patterns "$identifier") \
-       | if [ "$kflag" = 'no' ]; then
-               sed -E 's/^[^: ]+:[0-9]+:/\n\n&\n/';
-       else
-               cat;
-       fi \
-       | if [ "$cflag" = 'yes' ]; then
-               perl -pe 's/('"$identifier"')/\033[32m\1\033[0m/';
-       else
-               cat;
-       fi;
+       | sed -E -f <(test "$kflag" = 'no'  && echo 's/^[^: ]+:[0-9]+:/\n\n&\n/') \
+       | perl -pe "$(test "$cflag" = 'yes' && echo 's/('"$identifier"')/\033[32m\1\033[0m/' || echo 's///')";
 }