which-first
v0.1.0
Published
Show which copy of a command your shell will actually run, and every other copy shadowed behind it.
Readme
which-first
Show which copy of a command your shell will actually run, and every other copy that exists but never will.
npm: C:\tools\npm.cmd
shadowed: C:\Program Files\nodejs\npm.cmd
shadowed: C:\Program Files\nodejs\npm.ps1The problem it exists for
where npm lists every copy. It does not tell you which one wins, and on
Windows the answer is not obvious: npm.cmd beats npm.exe because of
PATHEXT, and the first directory on PATH beats all the later ones. People
install a tool, run it, and get the old copy that happens to sit earlier on
PATH. which-first prints the winner first and labels the rest shadowed.
Install
npm install which-firstNode 18 or newer. No dependencies.
Use
which-first npm
which-first node git pythonExit code 0 when every command resolves, 1 when one does not, 2 when
you give it nothing to look up.
Resolution follows the shell: directories in PATH order, PATHEXT
extensions in order, case-insensitive on Windows, repeated directories
skipped. A directory that does not exist is ignored rather than reported as
an error.
