Repository navigation
powershell: escape all five single-quote characters - #258
Merged
casperdcl merged 2 commits intoSep 1, 2026
Merged
Conversation
Co-authored-by: Claude <noreply@anthropic.com>
casperdcl
force-pushed
the
powershell-escape-all-quote-chars
branch
from
September 1, 2026 22:06
cfc783d to
0d60059
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #258 +/- ##
=======================================
Coverage 87.83% 87.83%
=======================================
Files 4 4
Lines 666 666
Branches 138 138
=======================================
Hits 585 585
Misses 43 43
Partials 38 38 🚀 New features to boost your workflow:
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PowerShell closes a verbatim string literal on any of five characters — U+0027, U+2018, U+2019, U+201A and U+201B (Language Specification 3.0, §2.3.5.1.1
single-quote-character)._powershell_escapedoubles only the first three, so help text, an option string or a command name containing U+201A or U+201B emits a script PowerShell cannot parse.U+201A is the ordinary opening single quote in German, Czech, Slovak, Polish and Hungarian typography, so this is reachable from plain
help=text.Measured with
pwsh 7.6.5, parsing the output ofshtab.complete(parser, "powershell")via[Parser]::ParseFile— same script, same binary, before and after:Doubling is the right remedy for all five, not just a workaround:
'x<C><C>y'evaluates tox<C>ywith the original codepoint preserved, confirmed in pwsh for each of the five (8218and8219come back intact).How this was found: not from a bug report — a systematic pass over escaping/quoting tables in CLI tooling, checking each against the grammar it claims to implement. This one is a hand-written character set with no test covering it, so a character the grammar lists and the set omits cannot fail anything.
_powershell_escapecurrently has no test at all; the new one is parametrized over all five characters so the set can't silently fall behind again.Verified:
pytest tests/,pwshon PATH for every run — 100 passed / 56 skipped before, 105 passed / 56 skipped after (the 5 new parametrized cases). Reverting onlyshtab/__init__.pyand keeping the test: 2 failed / 103 passed / 56 skipped. Two naive alternatives also fail it — normalising all five to an ASCII apostrophe (4 failed; it parses but corrupts the text) and adding only U+201A (1 failed).pre-commit runon both changed files: all 22 hooks pass.Not tested: only
pwsh7.6.5 on macOS/arm64. Windows PowerShell 5.1 was not available to me; the grammar is the same but I did not confirm it there.AI assistance: this change was written with Claude Code (model Claude Opus 5). I reviewed the diff and ran everything reported above.