summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJoão Reis <reis@janeasystems.com>2019-09-03 16:44:50 +0100
committerRich Trott <rtrott@gmail.com>2019-09-05 19:14:29 -0700
commit7bff96204bd2c4de4f7ff294d8d6be5a9c53c8d4 (patch)
treed835f7ad99f1455793acd20979dfed869ee49457 /tools
parent2882ce911df821895c70d2ee99a88a4554fa3221 (diff)
downloadandroid-node-v8-7bff96204bd2c4de4f7ff294d8d6be5a9c53c8d4.tar.gz
android-node-v8-7bff96204bd2c4de4f7ff294d8d6be5a9c53c8d4.tar.bz2
android-node-v8-7bff96204bd2c4de4f7ff294d8d6be5a9c53c8d4.zip
build,win: fix Python detection on localized OS
This code previously assumed the default value was always printed to the console by reg.exe as "(default)", but this is not true on localized versions of Windows and can contain spaces. Fixes: https://github.com/nodejs/node/issues/29417 PR-URL: https://github.com/nodejs/node/pull/29423 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: David Carlier <devnexen@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/msvs/find_python.cmd18
1 files changed, 10 insertions, 8 deletions
diff --git a/tools/msvs/find_python.cmd b/tools/msvs/find_python.cmd
index cb98f9df43..728eeb405b 100644
--- a/tools/msvs/find_python.cmd
+++ b/tools/msvs/find_python.cmd
@@ -60,14 +60,16 @@ exit /b 1
:: Read the InstallPath of a given Environment Key to %p%
:: https://www.python.org/dev/peps/pep-0514/#installpath
:read-installpath
-:: %%a will receive token 3
-:: %%b will receive *, corresponding to token 4 and all after
-for /f "skip=2 tokens=3*" %%a in ('reg query "%1\InstallPath" /ve /t REG_SZ 2^> nul') do (
- set "head=%%a"
- set "tail=%%b"
- set "p=!head!"
- if not "!tail!"=="" set "p=!head! !tail!"
- exit /b 0
+:: %%a will receive everything before ), might have spaces depending on language
+:: %%b will receive *, corresponding to everything after )
+:: %%c will receive REG_SZ
+:: %%d will receive the path, including spaces
+for /f "skip=2 tokens=1* delims=)" %%a in ('reg query "%1\InstallPath" /ve /t REG_SZ 2^> nul') do (
+ for /f "tokens=1*" %%c in ("%%b") do (
+ if not "%%c"=="REG_SZ" exit /b 1
+ set "p=%%d"
+ exit /b 0
+ )
)
exit /b 1