From eb33978b60ba6ebb170e5d5cf2c16fac0eec36d8 Mon Sep 17 00:00:00 2001 From: Slava Kim Date: Mon, 9 Mar 2015 12:05:02 -0700 Subject: [PATCH] Always guard leaking env variables on Windows with SETLOCAL/ENDOCAL Windows-only --- meteor.bat | 2 ++ tools/files.js | 4 +++- tools/tests/fake-mongod/fake-mongod.bat | 11 +++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/meteor.bat b/meteor.bat index 9e07ae78d3..451792a1c9 100644 --- a/meteor.bat +++ b/meteor.bat @@ -1,5 +1,6 @@ @echo off +SETLOCAL rem only if we are running from a checkout IF EXIST "%~dp0\.git" ( rem verify that we have 7zip in the path @@ -37,4 +38,5 @@ IF EXIST "%~dp0\.git" ( SET NODE_PATH=%~dp0\dev_bundle\lib\node_modules "%~dp0\dev_bundle\bin\node.exe" "%~dp0\tools\main.js" %* +ENDLOCAL diff --git a/tools/files.js b/tools/files.js index 9bb78abb70..19a9698326 100644 --- a/tools/files.js +++ b/tools/files.js @@ -1185,11 +1185,13 @@ files._generateScriptLinkToMeteorScript = function (scriptLocation) { var newScript = [ "@echo off", - "set METEOR_INSTALLATION=%~dp0%", + "SETLOCAL", + "SET METEOR_INSTALLATION=%~dp0%", // always convert to Windows path since this function can also be // called on Linux or Mac when we are building bootstrap tarballs "\"" + scriptLocationConverted + "\" %*", + "ENDLOCAL", // add a comment with the destination of the link, so it can be read later // by files.readLinkToMeteorScript "rem " + scriptLocationConverted, diff --git a/tools/tests/fake-mongod/fake-mongod.bat b/tools/tests/fake-mongod/fake-mongod.bat index ee38104519..88d4f550cb 100644 --- a/tools/tests/fake-mongod/fake-mongod.bat +++ b/tools/tests/fake-mongod/fake-mongod.bat @@ -1,10 +1,13 @@ REM Find the top of the tools tree (not to be confused with the 'tools' REM directory in that tree) -set TOOLS_DIR="%~dp0\..\..\.." +SETLOCAL +SET TOOLS_DIR="%~dp0\..\..\.." REM Find our binary dependencies (node). -set DEV_BUNDLE="%TOOLS_DIR%\dev_bundle" +SET DEV_BUNDLE="%TOOLS_DIR%\dev_bundle" REM Have at it! -set NODE_PATH="%DEV_BUNDLE%\lib\node_modules" -"%DEV_BUNDLE%\bin\node" "%~dp0\fake-mongod.js" %* \ No newline at end of file +SET NODE_PATH="%DEV_BUNDLE%\lib\node_modules" +"%DEV_BUNDLE%\bin\node" "%~dp0\fake-mongod.js" %* +ENDLOCAL +