aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2023-01-18 18:15:18 +0000
committerSam James <sam@gentoo.org>2023-01-18 18:16:40 +0000
commit5b1b482e139e9b1959ec70335aa844c258a60f4e (patch)
tree228d66d70a4871d1764563c6db88749b6d6dc352
parentRemoved py3.8→3.9 reports (diff)
downloadqa-scripts-5b1b482e139e9b1959ec70335aa844c258a60f4e.tar.gz
qa-scripts-5b1b482e139e9b1959ec70335aa844c258a60f4e.tar.bz2
qa-scripts-5b1b482e139e9b1959ec70335aa844c258a60f4e.zip
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@gentoo.org> Signed-off-by: Sam James <sam@gentoo.org>
-rwxr-xr-xeapi-usage.sh10
1 files 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 ${?}