Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 646588 (which-hunt) - [TRACKER] Remove sys-apps/which from @system
Summary: [TRACKER] Remove sys-apps/which from @system
Status: CONFIRMED
Alias: which-hunt
Product: Gentoo Linux
Classification: Unclassified
Component: Profiles (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Quality Assurance Team
URL: https://lwn.net/Articles/874049/
Whiteboard:
Keywords: PullRequest, Tracker
Depends on: 920023 926270 934067 940338 940347 940481 940563 940593 940621 940711 940717 941448 941512 941586 941724 941862 941887 941897 942552 942995 943151 943394 943523 944405 945805 946673 946677 946697 946713 946729 946783 946813 946959 947012 102464 502084 828100 844088 844094 844109 844169 844865 844868 844886 844901 845141 851018 853271 868486 877477 930088 931122 940218 940450 940568 940602 940692 941755 941942 942366 942752 947330
Blocks:
  Show dependency tree
 
Reported: 2018-02-04 17:01 UTC by Michał Górny
Modified: 2025-01-11 19:59 UTC (History)
7 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-02-04 17:01:16 UTC
Let's work on removing sys-apps/which from the @system set. It is not listed as a required command by POSIX, and it is entirely superficial on any system with POSIX shell, with the shell providing a more reliable built-ins that don't reinvent the wheel.

If any packages really rely on which, they should depend on it explicitly and preferably be fixed upstream to use shell builtin 'type -P' or likewise.
Comment 1 Larry the Git Cow gentoo-dev 2022-12-06 05:45:11 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1769ce6cb3a9b6273033158574ed833b11eb7d0d

commit 1769ce6cb3a9b6273033158574ed833b11eb7d0d
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2022-12-06 05:44:04 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-12-06 05:44:04 +0000

    postgres.eclass: stop using which(1)
    
    It's non-portable and we're looking to remove it from @system.
    
    Bug: https://bugs.gentoo.org/646588
    Signed-off-by: Sam James <sam@gentoo.org>

 eclass/postgres.eclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=da744421aa59fbf4e05b92702dae88dcb7af33d4

commit da744421aa59fbf4e05b92702dae88dcb7af33d4
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2022-12-06 05:44:03 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-12-06 05:44:03 +0000

    postgres-multi.eclass: stop using which(1)
    
    It's non-portable and we're looking to remove it from @system.
    
    Bug: https://bugs.gentoo.org/646588
    Signed-off-by: Sam James <sam@gentoo.org>

 eclass/postgres-multi.eclass | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=88389031f2b0377f449ed0c6cd65c85a989b8470

commit 88389031f2b0377f449ed0c6cd65c85a989b8470
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2022-12-06 05:44:03 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-12-06 05:44:03 +0000

    usr-ldscript.eclass: stop using which(1)
    
    It's non-portable and we're looking to remove it from @system.
    
    Bug: https://bugs.gentoo.org/646588
    Signed-off-by: Sam James <sam@gentoo.org>

 eclass/usr-ldscript.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=88607de9c44a1b11017ecb7d2d5e8868c48b1695

commit 88607de9c44a1b11017ecb7d2d5e8868c48b1695
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2022-12-06 05:44:03 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-12-06 05:44:03 +0000

    toolchain-funcs.eclass: stop using which(1)
    
    It's non-portable and we're looking to remove it from @system.
    
    Bug: https://bugs.gentoo.org/487696
    Bug: https://bugs.gentoo.org/646588
    Signed-off-by: Sam James <sam@gentoo.org>

 eclass/toolchain-funcs.eclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 2 Eli Schwartz gentoo-dev 2024-09-27 13:19:41 UTC
It was brought to my attention in bug 940218 that it turns out the first comment has incorrect information that will not result in a valid fix.


(In reply to Michał Górny from comment #0)
> Let's work on removing sys-apps/which from the @system set. It is not listed
> as a required command by POSIX, and it is entirely superficial on any system
> with POSIX shell, with the shell providing a more reliable built-ins that
> don't reinvent the wheel.
> 
> If any packages really rely on which, they should depend on it explicitly
> and preferably be fixed upstream to use shell builtin 'type -P' or likewise.


"type -P" is not listed as a required command by POSIX and the shell does not provide such a built-in at all (unless you happen to use bash).

For scripts that use #!/bin/bash in the shebang, it remains acceptable to use "type -P"

For ./configure scripts, or any other scripts that use #!/bin/sh in the shebang, one *must* use "command -v" instead. It is weaker in the event that one looks for a command that the shell provides, e.g. "command -v true", as it will return the first available command, and not guarantee it is an executable file on disk, but it works in nearly all cases.


If you use "type -P" for non-bash scripts then your package will instead have a new bug report opened against it blocking the bug 526268 tracker instead of this tracker.