Update gibMacOS.bat

This commit is contained in:
CorpNewt 2020-07-15 16:25:40 -05:00 committed by GitHub
parent 3a1c52e773
commit b142bf2655
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,8 +20,7 @@ REM FORCE = Use py3
set "use_py3=TRUE" set "use_py3=TRUE"
REM Get the system32 (or equivalent) path REM Get the system32 (or equivalent) path
call :setcomspec call :getsyspath "syspath"
set "syspath=%ComSpec:cmd.exe=%"
goto checkscript goto checkscript
@ -46,14 +45,14 @@ if not exist "!thisDir!\!script_name!" (
) )
goto checkpy goto checkpy
:setcomspec :getsyspath <variable_name>
REM Helper method to return the "proper" path to cmd.exe, reg.exe, and where.exe by walking the ComSpec var 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 REM Prep the LF variable to use the "line feed" approach
(SET LF=^ (SET LF=^
%=this line is empty=% %=this line is empty=%
) )
REM Strip double semi-colons REM Strip double semi-colons
call :undouble "ComSpec" ";" call :undouble "ComSpec" "%ComSpec%" ";"
set "testpath=%ComSpec:;=!LF!%" set "testpath=%ComSpec:;=!LF!%"
REM Let's walk each path and test if cmd.exe, reg.exe, and where.exe exist there REM Let's walk each path and test if cmd.exe, reg.exe, and where.exe exist there
set /a found=0 set /a found=0
@ -76,6 +75,7 @@ for /f "tokens=* delims=" %%i in ("!testpath!") do (
if EXIST "!temppath!where.exe" ( if EXIST "!temppath!where.exe" (
set /a found=1 set /a found=1
set "ComSpec=!temppath!cmd.exe" set "ComSpec=!temppath!cmd.exe"
set "%~1=!temppath!"
) )
) )
) )
@ -100,17 +100,16 @@ if not "%spath%" == "" (
set "PATH=%upath%" set "PATH=%upath%"
) )
REM Remove double semicolons from the adjusted PATH REM Remove double semicolons from the adjusted PATH
call :undouble "PATH" ";" call :undouble "PATH" "%PATH%" ";"
goto :EOF goto :EOF
:undouble <string_name> <character> :undouble <string_name> <string_value> <character>
REM Helper function to strip doubles of a single character out of a string recursively REM Helper function to strip doubles of a single character out of a string recursively
set "string_name=%~1" set "string_value=%~2"
set "character=%~2" set "check=!string_value:%~3%~3=%~3!"
set "check=!%string_name%:%character%%character%=%character%!" if not "!check!" == "!string_value!" (
if not "!check!" == "!%~1!" ( set "%~1=!check!"
set "!string_name!=!check!" call :undouble "%~1" "!check!" "%~3"
call :undouble "%~1" "%~2"
) )
goto :EOF goto :EOF
@ -132,35 +131,32 @@ if /i "!use_py3!" == "FALSE" (
if not "!pypath!" == "" ( if not "!pypath!" == "" (
goto runscript goto runscript
) )
if !tried! lss 1 (
if "!pypath!" == "" ( if /i "!toask!"=="yes" (
if %tried% lss 1 ( REM Better ask permission first
if /i "!toask!"=="yes" ( goto askinstall
REM Better ask permission first
goto askinstall
) else (
goto installpy
)
) else ( ) else (
cls goto installpy
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
) )
) 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 goto runscript
@ -240,7 +236,7 @@ if /i "!menu!"=="y" (
goto installpy goto installpy
) else if "!menu!"=="n" ( ) else if "!menu!"=="n" (
REM No OK here... REM No OK here...
set /a tried=%tried%+1 set /a tried=!tried!+1
goto checkpy goto checkpy
) )
REM Incorrect answer - go back REM Incorrect answer - go back
@ -249,7 +245,7 @@ goto askinstall
:installpy :installpy
REM This will attempt to download and install python REM This will attempt to download and install python
REM First we get the html for the python downloads page for Windows REM First we get the html for the python downloads page for Windows
set /a tried=%tried%+1 set /a tried=!tried!+1
cls cls
echo ### ### echo ### ###
echo # Installing Python # echo # Installing Python #