[Fix] Escape backslashes in PowerShell ArgumentList #3658
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backslashes are mostly fine to just include without escaping, but there are certain cases where they can cause issues. One of those would be when specifying just a drive letter (
X:\
) as one argument (for example as the install path for a game). In that case, when adding the necessary escape characters around the argument, we'd end up with"`"X:\`""
. PS would then see that the backtick is escaped by a \ (even though it's not supposed to be), and the whole thing would fall apartResolving this is luckily rather easy, we can simply replace every one \ with two \ to end up with one escaped \, which can then no longer break anything around it
To test:
D:\
)This still needs a bit more testing with uncommon arguments, PS is pretty unpredictable after allUse the following Checklist if you have changed something on the Backend or Frontend: