From b142bf2655dc998fa7a47d41b3f28d93bd660e30 Mon Sep 17 00:00:00 2001 From: CorpNewt <12772521+corpnewt@users.noreply.github.com> Date: Wed, 15 Jul 2020 16:25:40 -0500 Subject: [PATCH] Update gibMacOS.bat --- gibMacOS.bat | 78 +++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/gibMacOS.bat b/gibMacOS.bat index 611af98..04655d9 100644 --- a/gibMacOS.bat +++ b/gibMacOS.bat @@ -20,8 +20,7 @@ REM FORCE = Use py3 set "use_py3=TRUE" REM Get the system32 (or equivalent) path -call :setcomspec -set "syspath=%ComSpec:cmd.exe=%" +call :getsyspath "syspath" goto checkscript @@ -46,14 +45,14 @@ if not exist "!thisDir!\!script_name!" ( ) goto checkpy -:setcomspec +:getsyspath REM Helper method to return the "proper" path to cmd.exe, reg.exe, and where.exe by walking the ComSpec var REM Prep the LF variable to use the "line feed" approach (SET LF=^ %=this line is empty=% ) REM Strip double semi-colons -call :undouble "ComSpec" ";" +call :undouble "ComSpec" "%ComSpec%" ";" set "testpath=%ComSpec:;=!LF!%" REM Let's walk each path and test if cmd.exe, reg.exe, and where.exe exist there set /a found=0 @@ -76,6 +75,7 @@ for /f "tokens=* delims=" %%i in ("!testpath!") do ( if EXIST "!temppath!where.exe" ( set /a found=1 set "ComSpec=!temppath!cmd.exe" + set "%~1=!temppath!" ) ) ) @@ -100,17 +100,16 @@ if not "%spath%" == "" ( set "PATH=%upath%" ) REM Remove double semicolons from the adjusted PATH -call :undouble "PATH" ";" +call :undouble "PATH" "%PATH%" ";" goto :EOF -:undouble +:undouble REM Helper function to strip doubles of a single character out of a string recursively -set "string_name=%~1" -set "character=%~2" -set "check=!%string_name%:%character%%character%=%character%!" -if not "!check!" == "!%~1!" ( - set "!string_name!=!check!" - call :undouble "%~1" "%~2" +set "string_value=%~2" +set "check=!string_value:%~3%~3=%~3!" +if not "!check!" == "!string_value!" ( + set "%~1=!check!" + call :undouble "%~1" "!check!" "%~3" ) goto :EOF @@ -132,35 +131,32 @@ if /i "!use_py3!" == "FALSE" ( if not "!pypath!" == "" ( goto runscript ) - -if "!pypath!" == "" ( - if %tried% lss 1 ( - if /i "!toask!"=="yes" ( - REM Better ask permission first - goto askinstall - ) else ( - goto installpy - ) +if !tried! lss 1 ( + if /i "!toask!"=="yes" ( + REM Better ask permission first + goto askinstall ) else ( - cls - echo ### ### - echo # Warning # - echo ### ### - echo. - REM Couldn't install for whatever reason - give the error message - echo Python is not installed or not found in your PATH var. - echo Please install it from https://www.python.org/downloads/windows/ - echo. - echo Make sure you check the box labeled: - echo. - echo "Add Python X.X to PATH" - echo. - echo Where X.X is the py version you're installing. - echo. - echo Press [enter] to quit. - pause > nul - exit /b + goto installpy ) +) else ( + cls + echo ### ### + echo # Warning # + echo ### ### + echo. + REM Couldn't install for whatever reason - give the error message + echo Python is not installed or not found in your PATH var. + echo Please install it from https://www.python.org/downloads/windows/ + echo. + echo Make sure you check the box labeled: + echo. + echo "Add Python X.X to PATH" + echo. + echo Where X.X is the py version you're installing. + echo. + echo Press [enter] to quit. + pause > nul + exit /b ) goto runscript @@ -240,7 +236,7 @@ if /i "!menu!"=="y" ( goto installpy ) else if "!menu!"=="n" ( REM No OK here... - set /a tried=%tried%+1 + set /a tried=!tried!+1 goto checkpy ) REM Incorrect answer - go back @@ -249,7 +245,7 @@ goto askinstall :installpy REM This will attempt to download and install python REM First we get the html for the python downloads page for Windows -set /a tried=%tried%+1 +set /a tried=!tried!+1 cls echo ### ### echo # Installing Python #