commit: 7086a89128a08b08379699fa155d035d255d4d07
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Fri Jul 26 01:16:31 2024 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri May 30 07:35:53 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=7086a891
60openrc: read and check shebangs more efficiently
Don't bother calling head(1). Instead, use the read builtin. Don't open
and read from files twice. Use an extglob rather than a (slower) regex.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/install-qa-check.d/60openrc | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/bin/install-qa-check.d/60openrc b/bin/install-qa-check.d/60openrc
index 6c9c28795e..8b881d2ff2 100644
--- a/bin/install-qa-check.d/60openrc
+++ b/bin/install-qa-check.d/60openrc
@@ -10,9 +10,12 @@ openrc_check() {
# if empty conf.d/init.d dir exists (baselayout), then
i will be "/etc/conf.d/*" and not exist
[[ ! -e ${i} ]] && continue
if [[ ${d} == /etc/init.d && ${i} != *.sh ]] ; then
- # skip non-shell-script for bug #451386
- [[ $(head -n1 "${i}") =~
^#!.*[[:space:]/](openrc-run|runscript|sh)$ ]] || continue
- if [[ $(head -n1 "${i}") == '#!/sbin/runscript'
]] ; then
+ if ! read -r < "${i}" ; then
+ continue
+ elif [[ ${REPLY} !=
'#!'*[[:blank:]/]@(openrc-run|runscript|sh) ]] ; then
+ # skip non-shell-script for bug #451386
+ continue
+ elif [[ ${REPLY} == '#!/sbin/runscript' ]] ;
then
eqawarn "QA Notice: #!/sbin/runscript
is deprecated, use #!/sbin/openrc-run instead:"
while read -r ;
do eqawarn " ${REPLY}"