You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 9, 2017. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 9, 2017. It is now read-only.
gitk.cmd fails when user profile folder name has ampersand symbol #245
The gitk.cmd script will fail in this case because & is recognized as joining two commands in a batch script, unless if the path is double quoted.
The easiest fix for this is to use "delayed expansion" coupled with ! (instead of %) to demarcate the environment variable names.
Fixed script:
@rem Do not use "echo off" to not affect any child calls.
@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!
@if not exist "!HOME!" @set HOME=!HOMEDRIVE!!HOMEPATH!
@if not exist "!HOME!" @set HOME=!USERPROFILE!
@start "gitk" wish.exe "!git_install_root!\bin\gitk" -- %*
Original script:
@rem Do not use "echo off" to not affect any child calls.
@setlocal
@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%
@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%
@start "gitk" wish.exe "%git_install_root%\bin\gitk" -- %*
This is not about laziness BTW, but also about things like maintaining correct authorship and giving proper credit.
Well, not to forget about the respect and gratitude to contribute back to a project that lives on contributions. Never forget that this project is built on a great community, and you have the opportunity to be part of that community. By contributing.
Assume the user profile is in
C:\Users\A&E\.The
gitk.cmdscript will fail in this case because&is recognized as joining two commands in a batch script, unless if the path is double quoted.The easiest fix for this is to use "delayed expansion" coupled with
!(instead of%) to demarcate the environment variable names.Fixed script:
Original script:
Related Stack Overflow question for more information (Disclaimer: posted by me)