On Fri, 14 Aug 2020 at 00:55:03 +0200, Erik Gustafsson wrote: > This "which" is heavily used at the company where I work, for java > development etc like > which -s java || echo "You have to install java to run this program"
Another angle you could attack this from is to change these scripts to use "which java >/dev/null" or, better, "command -v java >/dev/null" instead of "which -s java". which(1) is non-standardized, which is likely to be part of the reason why Debian has its own implementation not shared with other Linux distributions. Some other Linux distributions, for example Fedora and Arch Linux, use GNU Which <https://savannah.gnu.org/projects/which/> and that doesn't seem to support the -s option either (but does support a lot of other non-standard options). Adding a -s option to the debianutils implementation of `which` will help your scripts to run on Debian and (eventually) Debian derivatives like Ubuntu, but won't help your scripts to run on Fedora or Arch. Other distributions might be using debianutils `which` like Debian, GNU Which like Fedora, or some third implementation. command(1) is specified by POSIX (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html) and should be available on all Unix-like systems, with at least the options documented in POSIX. (This is not a reason to reject the addition of a -s option to which - if users of other systems expect that option, it might as well exist - but it might well be a quicker route to portability than patching all the implementations of which.) smcv