I have several places on my computer that have executables, and they are all added to the PATH
.
Occasionally, there are cases where I have multiple executables with the same name that either have different configurations or do different things entirely. For example I have the native Windows FIND
command, and I also have the Linux port of find
for windows. Both of these are very useful in their own right, but do very different things.
When I execute FIND
from the command line; by default the Windows version executes unless I am in the directory with the Unix version. In this case, this is mostly what I want, but there are situations that are different. I know the executable that will run will always be the one outputted when I type which
.
My question is: How is that executable chosen over the other? Why does Windows choose Git
located at ...\msysgit\bin\git.exe
vs the one located at D:\bin\git.exe
? Both locations are on the PATH
. Is it something as silly as the order of the PATH
entries?
Answer
Windows first checks the current working directory, then checks each path in the PATH variable from left to right, and finally checks system locations (e.g. %WINDIR%). This is almost identical to Linux, except Linux does not check "." before PATH.
No comments:
Post a Comment