Skip to content

[v2] Double-quote Windows alias commands#10223

Open
hssyoo wants to merge 2 commits intov2from
alias-escape
Open

[v2] Double-quote Windows alias commands#10223
hssyoo wants to merge 2 commits intov2from
alias-escape

Conversation

@hssyoo
Copy link
Copy Markdown
Contributor

@hssyoo hssyoo commented Apr 14, 2026

_windows_shell_quote() only escapes for the MSVC C runtime argv parser (backslashes and double quotes) but
does not account for cmd.exe metacharacters. When ExternalAliasCommand passes user-supplied arguments through subprocess.call(command, shell=True), the string is interpreted by cmd.exe before reaching the target process, meaning metacharacters aren't properly escaped.

This PR fixes the issue by always double-quoting the alias value string when shell=True, automatically treating metacharacters as literals.

NOTE: %VAR% expansion and !VAR! delayed expansion cannot be reliably escaped inside double quotes in cmd.exe /c. %% doubling only works in batch file mode. There is no known reliable escape for % or ! inside double quotes on the command line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant