From 48334dc0b1b8211f07b2fac5a00a41be58c0c3ee Mon Sep 17 00:00:00 2001 From: isaacs Date: Wed, 5 Jan 2011 11:12:36 -0800 Subject: [PATCH] Fix regression introduced in fe804d9b It breaks argv[0] on posix systems, and makes it so that npm can't determine whether node was run from an explicit location, or via "node", so the configs default improperly. If on windows, don't do this behavior. On posix, go back to the old behavior. --- src/node.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/node.js b/src/node.js index b99476427c..f6cc2392ce 100644 --- a/src/node.js +++ b/src/node.js @@ -536,10 +536,15 @@ var cwd = process.cwd(); var path = requireNative('path'); - - // Make process.argv[0] and process.argv[1] into full paths. - if ('/\\'.indexOf(process.argv[0].charAt(0)) < 0 - && process.argv[0].charAt(1) != ':') { + var isWindows = process.platform === 'win32'; + + // Make process.argv[0] and process.argv[1] into full paths, but only + // touch argv[0] if it's not a system $PATH lookup. + // TODO: Make this work on Windows as well. Note that "node" might + // execute cwd\node.exe, or some %PATH%\node.exe on Windows, + // and that every directory has its own cwd, so d:node.exe is valid. + var argv0 = process.argv[0]; + if (!isWindows && argv0.indexOf('/') !== -1 && argv0.charAt(0) !== '/') { process.argv[0] = path.join(cwd, process.argv[0]); }