From a6018d3fe8a4f618361f5d0a9c0e1ba0b0f3c1d8 Mon Sep 17 00:00:00 2001 From: ADTC Date: Mon, 15 Sep 2014 17:38:28 +0800 Subject: [PATCH] Use delayed expansion of environment variables With the immediate expansion, paths containing the ampersand symbol (&) will not work in this script. This is likely to occur when the user profile is located in a folder that contains the symbol in its name. The command processor misinterprets the symbol as to mean the union of two separate commands. To avoid the issue, "delayed expansion" is used and the environment variables are demarcated using the exclamation mark (!) instead of the percentage symbol (%). Signed-off-by: ADTC --- cmd/gitk.cmd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/gitk.cmd b/cmd/gitk.cmd index f55706bd..71ff96bd 100644 --- a/cmd/gitk.cmd +++ b/cmd/gitk.cmd @@ -1,12 +1,12 @@ @rem Do not use "echo off" to not affect any child calls. -@setlocal +@setlocal enableDelayedExpansion @rem Get the absolute path to the parent directory, which is assumed to be the @rem Git installation root. @for /F "delims=" %%I in ("%~dp0..") do @set git_install_root=%%~fI -@set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%PATH% +@set PATH=!git_install_root!\bin;!git_install_root!\mingw\bin;!PATH! -@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH% -@if not exist "%HOME%" @set HOME=%USERPROFILE% +@if not exist "!HOME!" @set HOME=!HOMEDRIVE!!HOMEPATH! +@if not exist "!HOME!" @set HOME=!USERPROFILE! -@start "gitk" wish.exe "%git_install_root%\bin\gitk" -- %* +@start "gitk" wish.exe "!git_install_root!\bin\gitk" -- %* -- 2.11.4.GIT