Skip to content

Commit

Permalink
Use env.PATH only, not env.Path
Browse files Browse the repository at this point in the history
Windows returns the value of %Path% from env.PATH anyway, because
environs are case-insensitive (but case-preserving) on Windows.

Reading from a Path environ on Unix systems sometimes causes strange
behavior

Fix #34
Close #35
  • Loading branch information
isaacs committed Jun 5, 2016
1 parent 34aac93 commit c7a1ac9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
21 changes: 5 additions & 16 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,14 @@ t.test('make executable', function (t) {
t.test('find when executable', function (t) {
var opt = { pathExt: '.sh' }
var expect = path.resolve(fixture, 'foo.sh').toLowerCase()
var PATH = process.env.PATH || process.env.Path
var PATH = process.env.PATH

t.test('absolute', function (t) {
runTest(fixture + '/foo.sh', t)
})

t.test('with process.env.PATH', function (t) {
process.env.PATH = process.env.Path = fixture
runTest('foo.sh', t)
})

t.test('with process.env.Path', {
skip: isWindows ? false : 'Only for Windows'
}, function (t) {
process.env.PATH = ""
process.env.Path = fixture
process.env.PATH = fixture
runTest('foo.sh', t)
})

Expand All @@ -92,17 +84,14 @@ t.test('find when executable', function (t) {
}, function (t) {
var pe = process.env.PATHEXT
process.env.PATHEXT = '.SH'
process.env.PATH = ""
process.env.Path = fixture
process.env.PATH = fixture

t.test('foo.sh', function (t) {
process.env.PATH = ""
process.env.Path = fixture
process.env.PATH = fixture
runTest('foo.sh', t)
})
t.test('foo', function (t) {
process.env.PATH = ""
process.env.Path = fixture
process.env.PATH = fixture
runTest('foo', t)
})
t.test('replace', function (t) {
Expand Down
2 changes: 1 addition & 1 deletion which.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function getNotFoundError (cmd) {

function getPathInfo (cmd, opt) {
var colon = opt.colon || COLON
var pathEnv = opt.path || process.env.Path || process.env.PATH || ''
var pathEnv = opt.path || process.env.PATH || ''
var pathExt = ['']

pathEnv = pathEnv.split(colon)
Expand Down

0 comments on commit c7a1ac9

Please sign in to comment.