More variable quoting in init.bat

There were problems when a path contained a parenthesis like `C:\temp\test (test)\`

As a precaution, quote all variables when they are used in echo or set.
This commit is contained in:
Jan Schulz 2016-05-06 15:06:59 +02:00
parent 1bf5503bea
commit 055a974257

14
vendor/init.bat vendored
View File

@ -8,7 +8,7 @@
:: Find root dir :: Find root dir
if not defined CMDER_ROOT ( if not defined CMDER_ROOT (
for /f "delims=" %%i in ("%ConEmuDir%\..\..") do set CMDER_ROOT=%%~fi for /f "delims=" %%i in ("%ConEmuDir%\..\..") do set "CMDER_ROOT=%%~fi"
) )
:: Remove trailing '\' :: Remove trailing '\'
@ -57,7 +57,7 @@ for /F "delims=" %%F in ('where git.exe') do @(
set "test_dir=!CD!" set "test_dir=!CD!"
popd popd
if exist "!test_dir!\cmd\git.exe" ( if exist "!test_dir!\cmd\git.exe" (
set GIT_INSTALL_ROOT=!test_dir! set "GIT_INSTALL_ROOT=!test_dir!"
set test_dir= set test_dir=
goto :FOUND_GIT goto :FOUND_GIT
) else ( ) else (
@ -80,14 +80,14 @@ if exist "%CMDER_ROOT%\vendor\git-for-windows" (
:: Add git to the path :: Add git to the path
if defined GIT_INSTALL_ROOT ( if defined GIT_INSTALL_ROOT (
rem add the unix commands at the end to not shadow windows commands like more rem add the unix commands at the end to not shadow windows commands like more
echo Enhancing PATH with unix commands from git [%GIT_INSTALL_ROOT%] echo Enhancing PATH with unix commands from git in "%GIT_INSTALL_ROOT%\usr\bin"
set "PATH=%PATH%;%GIT_INSTALL_ROOT%\usr\bin;%GIT_INSTALL_ROOT%\usr\share\vim\vim74" set "PATH=%PATH%;%GIT_INSTALL_ROOT%\usr\bin;%GIT_INSTALL_ROOT%\usr\share\vim\vim74"
:: define SVN_SSH so we can use git svn with ssh svn repositories :: define SVN_SSH so we can use git svn with ssh svn repositories
if not defined SVN_SSH set "SVN_SSH=%GIT_INSTALL_ROOT:\=\\%\\bin\\ssh.exe" if not defined SVN_SSH set "SVN_SSH=%GIT_INSTALL_ROOT:\=\\%\\bin\\ssh.exe"
) )
:NO_GIT :NO_GIT
endlocal & set PATH=%PATH% & set SVN_SSH=%SVN_SSH% & set GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT% endlocal & set "PATH=%PATH%" & set "SVN_SSH=%SVN_SSH%" & set "GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%"
:: Enhance Path :: Enhance Path
set "PATH=%CMDER_ROOT%\bin;%PATH%;%CMDER_ROOT%\" set "PATH=%CMDER_ROOT%\bin;%PATH%;%CMDER_ROOT%\"
@ -108,9 +108,9 @@ popd
:: Allows user to override default aliases store using profile.d :: Allows user to override default aliases store using profile.d
:: scripts run above. Note: If overriding default aliases file :: scripts run above. Note: If overriding default aliases file
:: in profile.d the aliases must also be loaded in profile.d. :: in profile.d the aliases must also be loaded in profile.d.
set user-aliases=%CMDER_ROOT%\config\user-aliases.cmd set "user-aliases=%CMDER_ROOT%\config\user-aliases.cmd"
if not defined aliases ( if not defined aliases (
set aliases=%user-aliases% set "aliases=%user-aliases%"
) )
:: make sure we have an example file :: make sure we have an example file
@ -139,7 +139,7 @@ if exist "%CMDER_ROOT%\vendor\git-for-windows\post-install.bat" (
) )
:: Set home path :: Set home path
if not defined HOME set HOME=%USERPROFILE% if not defined HOME set "HOME=%USERPROFILE%"
:: This is either a env variable set by the user or the result of :: This is either a env variable set by the user or the result of
:: cmder.exe setting this variable due to a commandline argument or a "cmder here" :: cmder.exe setting this variable due to a commandline argument or a "cmder here"