From 26fda46c01acce95d1dc86ad1f820bd624554b02 Mon Sep 17 00:00:00 2001 From: CorpNewt <12772521+corpnewt@users.noreply.github.com> Date: Wed, 1 Apr 2020 19:40:50 -0500 Subject: [PATCH] Update gibMacOS.bat --- gibMacOS.bat | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/gibMacOS.bat b/gibMacOS.bat index 4009cb0..87c8708 100644 --- a/gibMacOS.bat +++ b/gibMacOS.bat @@ -38,15 +38,28 @@ set "spath=" set "upath=" for /f "tokens=2* delims= " %%i in ('reg.exe query "HKCU\Environment" /v "Path" 2^> nul') do ( if not "%%j" == "" set "upath=%%j" ) for /f "tokens=2* delims= " %%i in ('reg.exe query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v "Path" 2^> nul') do ( if not "%%j" == "" set "spath=%%j" ) -if not "!spath!" == "" ( +if not "%spath%" == "" ( REM We got something in the system path - set "PATH=!spath!" + set "PATH=%spath%" if not "!upath!" == "" ( REM We also have something in the user path - set "PATH=!PATH!;!upath!" + set "PATH=%PATH%;%upath%" ) -) else if not "!upath!" == "" ( - set "PATH=!upath!" +) else if not "%upath%" == "" ( + set "PATH=%upath%" +) +REM Remove double semicolons from the adjusted PATH +call :undouble "PATH" ";" +goto :EOF + +: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" ) goto :EOF