From 27a937bcf824093b7707a845c6376cbaae1df78f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Maciej=20Ma=C5=82ecki?= Date: Fri, 24 Feb 2012 03:18:32 +0100 Subject: [PATCH] Revert "startup: use `path.resolve` instead of `path.join(cwd, ...)`" This reverts commit b0c15412270f32e00c268c578f07a1ed032323f5. Reverted commit introduced a regression causing `process.argv[0]` to be invalid in node processes spawned from `PATH` (without explicit path to executable file - for example when using global node installation). Instead of finding a correct path to the executable, `process.cwd()` would be prepended to `process.argv[0]`. --- src/node.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/node.js b/src/node.js index 8b7e7f9..176526a 100644 --- a/src/node.js +++ b/src/node.js @@ -433,14 +433,18 @@ startup.resolveArgv0 = function() { var cwd = process.cwd(); + var isWindows = process.platform === 'win32'; // Make process.argv[0] into a full path, 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 path = NativeModule.require('path'); - process.argv[0] = path.resolve(process.argv[0]); + var argv0 = process.argv[0]; + if (!isWindows && argv0.indexOf('/') !== -1 && argv0.charAt(0) !== '/') { + var path = NativeModule.require('path'); + process.argv[0] = path.join(cwd, process.argv[0]); + } }; // Below you find a minimal module system, which is used to load the node -- 2.7.4