From 9cf9d283626ee209b8538beb8f2d3d179bf63944 Mon Sep 17 00:00:00 2001 From: Kerin Millar Date: Mon, 26 Jun 2023 10:03:56 +0200 Subject: [PATCH] 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 (though it is unclear to me why ZIG_VER is exported at all). Signed-off-by: Kerin Millar Bug: https://bugs.gentoo.org/909163 --- 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 74c745fa8f..c6051d03e9 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/local/bin" fi export EZIG="${selected}" - export EZIG_VER="${ver}" + export EZIG_VER="${selected_ver}" } # Invoke zig with the optionally provided arguments. -- 2.39.3