From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1478428-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 82BC615800F
	for <garchives@archives.gentoo.org>; Wed, 18 Jan 2023 18:17:13 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id BD18EE08F1;
	Wed, 18 Jan 2023 18:17:12 +0000 (UTC)
Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id A2F9FE08F1
	for <gentoo-commits@lists.gentoo.org>; Wed, 18 Jan 2023 18:17:12 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 9FC75335DBA
	for <gentoo-commits@lists.gentoo.org>; Wed, 18 Jan 2023 18:17:11 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 0B67A771
	for <gentoo-commits@lists.gentoo.org>; Wed, 18 Jan 2023 18:17:10 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1674065800.5b1b482e139e9b1959ec70335aa844c258a60f4e.sam@gentoo>
Subject: [gentoo-commits] proj/qa-scripts:master commit in: /
X-VCS-Repository: proj/qa-scripts
X-VCS-Files: eapi-usage.sh
X-VCS-Directories: /
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 5b1b482e139e9b1959ec70335aa844c258a60f4e
X-VCS-Branch: master
Date: Wed, 18 Jan 2023 18:17:10 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: f7571aff-cb4f-426c-87d2-a657153960c6
X-Archives-Hash: 82cc21011d01b443d4b60f455f209881

commit:     5b1b482e139e9b1959ec70335aa844c258a60f4e
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 18 18:15:18 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jan 18 18:16:40 2023 +0000
URL:        https://gitweb.gentoo.org/proj/qa-scripts.git/commit/?id=5b1b482e

eapi-usage.sh: optimise + refactor

- Use Bash primitives (parameter expansion) to avoid cut/rev (2x) calls, as well
  as grep!

- Switch to while/read/find loop for improved robustness over while which
  can have issues wrt globbing/special file names.

Thanks to ulm for the suggestions.

Thanks-to: Ulrich Müller <ulm <AT> gentoo.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 eapi-usage.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/eapi-usage.sh b/eapi-usage.sh
index e4b65b2..62e878f 100755
--- a/eapi-usage.sh
+++ b/eapi-usage.sh
@@ -32,12 +32,12 @@ cd eapi-usage || exit 1
 
 ebegin "Finding ebuilds"
 (
-	for ebuild in $(find "${REPO_PATH}/metadata/md5-cache" -mindepth 2 -maxdepth 2 -type f -name '*-[0-9]*') ; do
-		cpf=$(echo ${ebuild} | rev | cut -d/ -f1-2 | rev)
-		eapi=$(grep -oi "eapi=.*" ${ebuild} | sed -e 's:EAPI=::')
-
+	while IFS= read -r ebuild ; do
+		cpf_eapi="${ebuild#${REPO_PATH}/metadata/md5-cache/}"
+		cpf="${cpf_eapi%%:*}"
+		eapi="${cpf_eapi##*:EAPI=}"
 		echo "${cpf}" >> ${eapi}.txt
-	done
+	done < <(find "${REPO_PATH}/metadata/md5-cache" -mindepth 2 -maxdepth 2 -type f -name '*-[0-9]*' -exec grep '^EAPI=' {} +)
 ) || { eend $? || exit 1; }
 eend ${?}