On Fri, 13 May 2022 09:11:30 +0200
Ulrich Mueller <u...@gentoo.org> wrote:

> Recently Debian has started to transition away from the "which"
> command. [1]
> 
> which is a non-POSIX command which prints out the location of
> specified executables that are in your path. Unfortunately, there are
> several versions of the program around which are not compatible with
> each other. We package the GNU version as sys-apps/which, which is in
> the system set since 2004.
> 
> Already in 2007, vapier asked developers to avoid which in ebuilds.
> [2] The replacement in most circumstances is "type -p" which is a bash
> builtin command.
> 
> So, should we join the "which hunt", with the goal of removing
> sys-apps/which from the system set and from stage1? I think the first
> step would be to identify which packages use which, and add it as an
> explicit dependency. (Maybe the tinderbox could help there?) A bug for
> this [3] has already been filed by mgorny some time ago.
> 
> Unfortunately, the command pops up in unexpected places, e.g. it
> appears to be an (indirect) build-time dependency of systemd. [4]
> 
> Ulrich
> 
> [1] https://lwn.net/Articles/874049/
> [2]
> https://archives.gentoo.org/gentoo-dev/message/e04d4db72572dd5fec48e87c6b18c525
> [3] https://bugs.gentoo.org/646588 [4] https://bugs.gentoo.org/502084

To solve this exact issue I wrote a pure shell script to find
executable files in the user's $PATH. It should work with posix
compatible shell and about as fast as which(1).

https://notabug.org/orbea/exists/src/master/exists.sh

There are a lot of tests as well.

https://notabug.org/orbea/exists/src/master/test.sh

Reply via email to