|
|
|
|
|
by Taywee
1695 days ago
|
|
In this case, `which` is just searching the `PATH` and not telling you what will actually run. `command` is correctly informing you of the whole story. I'll add that `which` on my setup is using the zsh built-in, which also informs of aliases and built-ins. So yes, that's more useful if you're using `which` to determine "Does this name exist as an executable anywhere in the PATH", but most people use it to mean "What will actually be executed if I run this word as a command?" edit: Or, most often in scripts, it's used just for its exit status to tell whether the command exists to be executed at all. |
|
You are assuming a bit too much here.
Which tells you the preferred executable with that name, while command tells you what will run if you execute it on the current shell.
From what I can tell, one does not replace the other. But yes, for your example of usage, command is more correct.