News for hackers. Stuff that matters.
Re:Which is not Posix by jonnycomputer on Monday November 01, 2021 @03:34PM (#29071846)
On Mac, with an alias I don't get the same answer from the two anyway:

  $ command -v emacs
  alias emacs='/Applications/Emacs.app/Contents/MacOS/Emacs -nw "$@"'

  $ which emacs
  /opt/local/bin/emacs
Re:Which is not Posix by jfrunyon on Monday November 01, 2021 @05:35PM (#29073460)
Correct, because they do two different things.

`which` is a standalone executable which searches the environment's PATH for the named command. It doesn't know about commands which aren't executables (i.e. builtins and aliases).

`command` is a shell builtin which tells you exactly what that shell in its current state would run.

Re:Which is not Posix by jonnycomputer on Monday November 01, 2021 @08:08PM (#29075142)
Interesting, and useful to know. Thanks for that.
Re:Which is not Posix by sigzero on Monday November 01, 2021 @03:47PM (#29072037)
That happens on every system I believe. It does for my RHEL boxes anyway. That also isn't the behavior I am looking for so I will stick with "which".
Re:Which is not Posix by jonnycomputer on Monday November 01, 2021 @08:04PM (#29075101)
I suspected it might, but was too lazy to check. Thanks for doing that.