From 279c73069f3c424768668aa8924d03a265ff4514 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Fri, 3 Nov 2023 18:23:44 +0100 Subject: bin/grepc: Compact code Signed-off-by: Alejandro Colomar --- bin/grepc | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/bin/grepc b/bin/grepc index 1a7b519..6d70f99 100755 --- 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///')"; } -- cgit v1.2.3