[Bug] When Git's path contains a closing parenthesis, "cmd" tasks end early and display '\Git\cmd\git.exe" found." was unexpected at this time.'
stanwest opened this issue · 3 comments
Version Information
Cmder version: 1.3.24.236
Operating system: Windows 11 21H2
Cmder Edition
Cmder Mini
Description of the issue
Suppose that the path to Git contains a closing parenthesis. When I start Cmder with a cmd
task such as {cmd::Cmder}
, Cmder displays the following message:
\Git\cmd\git.exe" found." was unexpected at this time.
This error interrupts the "init.bat" script. For example, it stopped before adding Cmder's "bin" directories to the path:
λ where cexec INFO: Could not find files for the given pattern(s).
How to reproduce
- Install/copy/link Git's program directory into a path that contains a ")" character.
- Ensure that the above path is in the
PATH
environment variable. - Launch Cmder such that it runs a
cmd
task (e..g, with argument/task {cmd::Cmder}
if necessary).
Additional context
The cause appears to be simply that the line below contains extra double quotation marks. Perhaps they were intended to delimit the path specified by the git_executable
variable, but because they instead end the quotation of "No git at " and begin the quotation of " found.", the value of git_executable
is unprotected from interpretation by the shell. When that value contains ")", it interferes with the parentheses in the surrounding if
and else
statements.
%print_debug% ":compare_git_versions" "No git at "%git_executable%" found."
Issue #2250 reports a similar symptom, but it is unclear what code was responsible or what commit or PR resolved the issue.
Checklist
- I have read the documentation.
- I have searched for similar issues and found none that describe my issue.
- I have reproduced the issue on the latest version of Cmder.
- I am certain my issues are not related to ConEmu, Clink, or other third-party tools that Cmder uses.
Thanks for the through investigation, I've merged the PR and hopefully this will indeed fix the issue.
Could you please also test the last CI master build on a Windows Sandbox environment with a path containing the )
character to see that it works properly?
Thank you for the fix!
Could you please also test the last CI master build on a Windows Sandbox environment with a path containing the
)
character to see that it works properly?
It appears to work. With cmder_mini.zip
from the build artifacts unpacked into C:\Users\WDAGUtilityAccount\cmder_mini
, PortableGit-2.46.0-64-bit.7z
unpacked into C:\Users\WDAGUtilityAccount\Portable)Git
, and C:\Users\WDAGUtilityAccount\Portable)Git\bin
appended to the path, Cmder launches successfully.
Thank you for the fix!
You're welcome!
@stanwest Thank you for the test and the PR!