]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
src/bin/grepc: -r: Simplify implementation, removing a conditional
authorAlejandro Colomar <alx@kernel.org>
Tue, 4 Nov 2025 14:18:43 +0000 (15:18 +0100)
committerAlejandro Colomar <alx@kernel.org>
Tue, 4 Nov 2025 14:21:37 +0000 (15:21 +0100)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/bin/grepc

index 70e312abe31c762d6d11e8b9a6157ba394d6e0d5..03db8e7effa4cd42dc3dc5d5796a3707700ccf5e 100755 (executable)
@@ -17,7 +17,7 @@ i='';
 l='';
 m='';
 n='';
-r='no';
+r='never';
 t='';
 x='c';
 
@@ -40,7 +40,7 @@ while getopts "A:B:C:chilm:nrt:x:" opt; do
        l)      l='-l';                 ;;
        m)      m="-m$OPTARG";          ;;
        n)      n='-n';                 ;;
-       r)      r='yes';                ;;
+       r)      r='always';             ;;
        t)      t="$t -t$OPTARG";       ;;
        x)      x="$OPTARG";            ;;
        \? | *) exit 2;                 ;;
@@ -77,11 +77,7 @@ else
        fi \
        | xargs -0 sh -c 'pcre2grep $opts -f "$0" -- "$@" || test $? -eq 1;' "$patterns";
 fi \
-| if test "$r" = 'yes'; then
-       grep -h --color=always -P "($identifier|^)";
-else
-       cat;
-fi \
+| grep -h --color="$r" -P "($identifier|^)" \
 | if test -n "$l"; then
        sort \
        | uniq;