On Fri, 14 Aug 2020 at 14:46:39 +0200, Jonas Smedegaard wrote:
> Regardless of the -s option, why is command preferred over which?  Due 
> to it being POSIX or for some other reason?

* command is POSIX, so any Unixish environment should have it, whereas
  which is non-standard, so it's anyone's guess whether it will exist
  on embedded, proprietary or otherwise limited Unixes
  (some upstream packages don't care about this, and Debian packages never
  have to, but for some upstream packages it matters)

* relatedly, the which "API" is Unix folklore rather than formally written
  down, so it's easy to rely on features of one implementation that others
  don't have, like this -s option; debianutils which only has one option,
  -a, and GNU which also has that option, but it wouldn't surprise me if
  implementations exist that don't have -a

* command is a shell builtin (I don't think the spec explicitly says so,
  but it can't work as documented unless it is), so "command -v java"
  is faster and more accurately reflects what your shell will actually do
  when you try to run java, typically on the next line of the same script

    smcv

Reply via email to