For most purposes, the difference is pretty nuanced and unlikely to cause a problem in real life.
> 'command -v' also returns 0 for shell built-ins, whereas 'which' only searches $PATH.
In what cases is one using anything to check for a built-in shell command? I've written quite a lot of bash, and this has never come up.
I've learned to prefer 'command -v' because it's always available, whereas on minimal or busybox installs sometimes 'which' is not included.
The annoying part seems to be more that the ergonomics of a single straightforwardly-named command (e.g. 'which') are friendlier and easier to remember compared to an unintuitively-named command requiring the addition of a flag.
Why can't we move in a more ergonomic direction by promoting 'which' to a BASH built-in?
metadat|3 years ago
> 'command -v' also returns 0 for shell built-ins, whereas 'which' only searches $PATH.
In what cases is one using anything to check for a built-in shell command? I've written quite a lot of bash, and this has never come up.
I've learned to prefer 'command -v' because it's always available, whereas on minimal or busybox installs sometimes 'which' is not included.
The annoying part seems to be more that the ergonomics of a single straightforwardly-named command (e.g. 'which') are friendlier and easier to remember compared to an unintuitively-named command requiring the addition of a flag.
Why can't we move in a more ergonomic direction by promoting 'which' to a BASH built-in?