Commit 2dece79
committed
install-from-source: avoid using
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]>which before it is installed1 parent 2bc4b4a commit 2dece79
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
0 commit comments