From 6a86348b811e3a0e8dabc9bfd973fb838bad2c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Mon, 7 Dec 2020 20:02:47 +0700 Subject: [PATCH] 99-pkglint-subpkgs: replace grep with case..esac On experience with 100 subpkgs, this change reduces execution time from 284ms to 4ms --- common/hooks/pre-pkg/99-pkglint-subpkgs.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/common/hooks/pre-pkg/99-pkglint-subpkgs.sh b/common/hooks/pre-pkg/99-pkglint-subpkgs.sh index fd1fee6c445..240d5ef0bc4 100644 --- a/common/hooks/pre-pkg/99-pkglint-subpkgs.sh +++ b/common/hooks/pre-pkg/99-pkglint-subpkgs.sh @@ -38,13 +38,17 @@ hook() { /subpackages/s/.*"//p s/".*//p }' $XBPS_SRCPKGDIR/$pkgname/template | - tr ' ' '\n' | sort)" + tr '\v\t\r\n' ' ')" for s in $subpkgs; do - grep -q "^$s$" <<< "$matches" || - msg_warn "${s}_package() defined but will never be built.\n" + case " $matches " in + *" $s "*) ;; + *) msg_warn "${s}_package() defined but will never be built.\n" ;; + esac done - grep -q "^$pkgname$" <<< "$matches" && - msg_warn "$pkgname is sourcepkg but is in subpackages=.\n" || : + case " $matches " in + *" $pkgname "*) + msg_warn "$pkgname is sourcepkg but is in subpackages=.\n" ;; + esac }