[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: The "which -s" flag



Quoting Simon McVittie (2020-08-14 14:29:15)
> 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.

Regardless of the -s option, why is command preferred over which?  Due 
to it being POSIX or for some other reason?

(I tried and failed duckduckgo'ing "which command"...)


 - Jonas

-- 
 * Jonas Smedegaard - idealist & Internet-arkitekt
 * Tlf.: +45 40843136  Website: http://dr.jones.dk/

 [x] quote me freely  [ ] ask before reusing  [ ] keep private

Attachment: signature.asc
Description: signature


Reply to: