3 ms·
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 "$@
by jonnycomputer 5y ago
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
- sigzero 5y agoThat 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".
- jonnycomputer 5y agoI suspected it might, but was too lazy to check. Thanks for doing that.
- jfrunyon 5y agoCorrect, 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.
- jonnycomputer 5y agoInteresting, and useful to know. Thanks for that.