You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
install-from-source: avoid using which before it is installed
The `which` executable must often be installed because it is missing
from many a Docker image. Therefore, it won't _really_ work if one
checks `which which` to figure out whether `which` is installed.
Let's avoid this by using `type`, which is a shell builtin for most
shells.
The `type` utility is specified in the POSIX standard, as per
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/type.html,
yet neither command-line options nor output is standardized. The only
thing we _can_ rely on is the exit status.
Note: _Technically_, this poses a change of behavior, as `which`
resolves only to executables that are on the `PATH` while `type` will
also happily report shell builtins. However, this is a net improvement:
If running the script in, say, BusyBox, where many of the common
utilities (including `which`!) are shell builtins, we would like to
avoid forcefully installing the packages without need.
Signed-off-by: Johannes Schindelin <[email protected]>
0 commit comments