Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 909163 - sys-fs/ncdu: Consider refraining from using compgen in the ebuild
Summary: sys-fs/ncdu: Consider refraining from using compgen in the ebuild
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Jakov Smolić
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2023-06-26 00:41 UTC by kfm
Modified: 2023-06-27 15:05 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
001-sys-fs-ncdu-refrain-from-using-compgen-to-locate-zig.patch (0001-sys-fs-ncdu-refrain-from-using-compgen-to-locate-zig.patch,3.99 KB, patch)
2023-06-26 02:00 UTC, kfm
Details | Diff
001-sys-fs-ncdu-refrain-from-using-compgen-to-locate-zig.patch (minimal) (0001-sys-fs-ncdu-refrain-from-using-compgen-to-locate-zig.patch,2.27 KB, patch)
2023-06-26 08:09 UTC, kfm
Details | Diff
0001-sys-fs-ncdu-refrain-from-using-compgen-to-locate-zig.patch (minimal, corrected diagnostic) (0001-sys-fs-ncdu-refrain-from-using-compgen-to-locate-zig.patch,2.26 KB, patch)
2023-06-26 08:16 UTC, kfm
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description kfm 2023-06-26 00:41:03 UTC
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.
Comment 1 kfm 2023-06-26 02:00:13 UTC
Created attachment 864618 [details, diff]
001-sys-fs-ncdu-refrain-from-using-compgen-to-locate-zig.patch
Comment 2 Florian Schmaus gentoo-dev 2023-06-26 07:15:31 UTC
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.
Comment 3 kfm 2023-06-26 08:09:46 UTC
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.
Comment 4 kfm 2023-06-26 08:13:24 UTC
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.
Comment 5 kfm 2023-06-26 08:16:46 UTC
Created attachment 864625 [details, diff]
0001-sys-fs-ncdu-refrain-from-using-compgen-to-locate-zig.patch (minimal, corrected diagnostic)

Per previous comment.
Comment 6 Larry the Git Cow gentoo-dev 2023-06-27 15:05:29 UTC
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(-)