Repository navigation
Fix gitk.cmd to work correctly when paths contain ampersand (&) symbol - #252
Conversation
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 <[email protected]>
Taking cue from start-ssh-agent.cmd, enhanced gitk.cmd to fallback to the immediate expansion script if delayed expansion is unavailable. Both script sections are the same, except for the different environment variable delimiters. When new changes are made, both sections must be updated correctly, taking care to use the correct delimiter (! or %) to demarcate the environment variables. (In fact, the fallback section is exactly the same as the original script before previous commit.) Signed-off-by: ADTC <[email protected]>
Fix gitk.cmd to work correctly when paths contain ampersand (&) symbol
|
Thank you so much for your contribution. This PR was truly a pleasure to review! |
|
Don't mention it :) I should thank you! 👍 The pleasure is all mine. I actually love writing good commit messages, and this has been a rewarding experience for me. And certainly learnt about proper contributor crediting :) Btw, I didn't look for any documentation about the "Signed-off-by:" line. I just followed the messages of the previous commits in the project. Hope I got it right. |
Yep, you got it right! The meaning of those lines is a little bit important, though: you state that you are allowed to contribute this work into Open Source (i.e. if you did this work on your employer's time, you have to be certain that it is okay to release the code into the open). |
|
Is this unrelated to the fix I already made with Git-Cheetah? msysgit/Git-Cheetah#17 |
|
@chaos7theory yep, it is unrelated. This here PR is about |
This is to fix the issue msysgit/git#245 I reported previously.
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.I have also enhanced the script to fall back to the original script code when delayed expansion is not available on the target computer system (in which case, a path containing ampersand may still cause the script to fail).