Skip to content

When single-quoting, don't also quote with backtick with PowerShell/pwsh

Matthew Bradburn requested to merge mbradburn/fix-powershell-over-quoting into main

What does this MR do?

It fixes by eliminating over-quoting in the git-fetch command.

Why was this MR needed?

In the issue's build output, we see an error about refs/heads/`#236-Admin-Video-Group-Page; with powershell the back-tick quoting is harmful when included in a single-quoted string.

PS /Users/mjb> echo "`# hello"
# hello
PS /Users/mjb> echo '`# hello'
`# hello

I was worried about branch names with special characters like double-quote (") but it also apparently doesn't need to be escaped when inside single quotes:

PS /Users/mjb> echo '"'
"

This also fixes git-fetch for branches with Chinese characters in the name, is that because we're applying an escape to those characters?

What's the best way to test this MR?

I tested this with pwsh on macos, and with powershell and pwsh on windows. Only the powershell executor is modified so I believe there's no impact on e.g. runners using bash.

What are the relevant issue numbers?

fixes #29606 (closed)

Edited by Romuald Atchadé

Merge request reports