npm / node-which

Like which(1) unix command. Find the first instance of an executable in the PATH.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

It does not find executable by relatative path on Linux

JustBlackBird opened this issue · comments

At the moment, the library does not find an executable specified with relative path. For example:

require('which')('./test/foo.sh', function(err) {
    if (err) {
        throw err;
    }
})

ends up with "not found" error even if the file is there and has correct execution permissions. The same works fine on windows.

Standard Linux which utility works fine in such cases.

Is search order used in Linux which utility is documented somewhere?

I've found sources of Debian which command. In that sources all input paths with at least one slash (/) are treated as relative ones. For such files values from PATH environment variable are not used.

The same behavior is described in COMMAND EXECUTION section of man bash (which is referenced by man which for search algorithm).

Should node-which works in the same way?

Thank you!