commit:     028a9bb68a31af8a43d2c1ce49fbbf3735a978e9
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Mon Jun 26 08:03:56 2023 +0000
Commit:     Florian Schmaus <flow <AT> gentoo <DOT> org>
CommitDate: Tue Jun 27 15:02:55 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=028a9bb6

sys-fs/ncdu: refrain from using compgen to locate zig

The availability of the compgen builtin depends on whether bash was
compiled with --enable-readline. As such, it is sensible to avoid it in
scripts intended for non-interactive shells.

Though it would have been straightforward to mimic the behaviour of
compgen -c, let's just search ${BROOT}/usr/bin instead. From what I can
gather, both dev-lang/zig and dev-lang/zig-bin install a (versioned)
symlink to /usr/bin, with there being no apparent need to search
elsewhere.

While at it, address an error of logic whereby ZIG_VER was defined as
the value of ver, rather than selected_ver.

Closes: https://bugs.gentoo.org/909163
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>

 sys-fs/ncdu/ncdu-2.2.2-r1.ebuild | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/sys-fs/ncdu/ncdu-2.2.2-r1.ebuild b/sys-fs/ncdu/ncdu-2.2.2-r1.ebuild
index 74c745fa8f11..fde041c1e0f4 100644
--- a/sys-fs/ncdu/ncdu-2.2.2-r1.ebuild
+++ b/sys-fs/ncdu/ncdu-2.2.2-r1.ebuild
@@ -49,21 +49,14 @@ zig-set_EZIG() {
                return
        fi
 
-       local candidates candidate selected selected_ver
+       local candidate selected selected_ver ver
 
-       candidates=$(compgen -c zig-)
-
-       for candidate in ${candidates}; do
-               if [[ ! ${candidate} =~ zig(-bin)?-([.0-9]+) ]]; then
+       for candidate in "${BROOT}"/usr/bin/zig-*; do
+               if [[ ! -L ${candidate} || ${candidate} != 
*/zig?(-bin)-+([0-9.]) ]]; then
                        continue
                fi
 
-               local ver
-               if (( ${#BASH_REMATCH[@]} == 3 )); then
-                       ver="${BASH_REMATCH[2]}"
-               else
-                       ver="${BASH_REMATCH[1]}"
-               fi
+               ver=${candidate##*-}
 
                if [[ -n ${EZIG_EXACT_VER} ]]; then
                        ver_test "${ver}" -ne "${EZIG_EXACT_VER}" && continue
@@ -96,11 +89,11 @@ zig-set_EZIG() {
        done
 
        if [[ -z ${selected} ]]; then
-               die "Could not find (suitable) zig installation in PATH"
+               die "Could not find (suitable) zig installation in 
${BROOT}/usr/bin"
        fi
 
        export EZIG="${selected}"
-       export EZIG_VER="${ver}"
+       export EZIG_VER="${selected_ver}"
 }
 
 # Invoke zig with the optionally provided arguments.

Reply via email to