While the compgen builtin is undeniably useful, it requires that bash be built with --enable-readline. It would be preferable for the sys-fs/ncdu ebuild to go about searching PATH by some other means. For some additional context, please refer to bug 909148. I have prepared a patch, which I shall attach shortly.
Created attachment 864618 [details, diff] 001-sys-fs-ncdu-refrain-from-using-compgen-to-locate-zig.patch
Thanks for pointing this out. The proposed patch looks good to me, but I would prefer keeping the indentation level low by inverting the candidate match logic and continuing the loop if there is no match, as the existing code did. As a further bonus point, this would probably make the diff of the patch much smaller, as more existing code could stay unchanged. If you don't want to change the patch, then please let us know. I am happy to apply it.
Created attachment 864624 [details, diff] 001-sys-fs-ncdu-refrain-from-using-compgen-to-locate-zig.patch (minimal) A minimalistic diff, as requested. Note that it still hoists the declaration of ver out of the loop. The reason for this is that locals are not lexically scoped in bash; to have local remain in the loop would incur a minor expense at best.
Sorry, ignore that one. My brain is not yet in full gear and there's a mistake in the diagnostic message. Corrected version coming right up.
Created attachment 864625 [details, diff] 0001-sys-fs-ncdu-refrain-from-using-compgen-to-locate-zig.patch (minimal, corrected diagnostic) Per previous comment.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=028a9bb68a31af8a43d2c1ce49fbbf3735a978e9 commit 028a9bb68a31af8a43d2c1ce49fbbf3735a978e9 Author: Kerin Millar <kfm@plushkava.net> AuthorDate: 2023-06-26 08:03:56 +0000 Commit: Florian Schmaus <flow@gentoo.org> CommitDate: 2023-06-27 15:02:55 +0000 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@plushkava.net> Signed-off-by: Florian Schmaus <flow@gentoo.org> sys-fs/ncdu/ncdu-2.2.2-r1.ebuild | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)