Skip to content

Add ConvertTo-PkArgumentString for quoting program arguments - #8

Merged
HalRiveria merged 2 commits into
mainfrom
feat/argument-quoting
Oct 28, 2026
Merged

HalRiveria merged 2 commits into
mainfrom
feat/argument-quoting

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

What was wrong. .NET Framework's ProcessStartInfo has no ArgumentList, so every command's Arguments was hand-built, like the README's '"{0}" "{0}.jxl"' -f $path. That breaks on a path with a quote in it or a trailing backslash ("C:\dir\" escapes its own closing quote).

What changed. New ConvertTo-PkArgumentString @($a, $b, ...) joins arguments into one command line using the C runtime's rules, which most Windows programs follow:

  • arguments with a space, tab, newline or quote are wrapped in quotes;
  • quotes inside them are escaped;
  • backslashes are doubled where they come before a quote or the closing quote;
  • empty arguments become "".

It's in the worker-safe list, so workers have it too. The README's examples use it, and the function table lists it.

Testing. Exact-output assertions for the tricky cases, plus a round trip: the harness compiles a tiny program with csc.exe that prints each argument it receives, and checks it gets back exactly the list given (spaces, empty, quotes, a\"b, a tab, x\y, trailing backslashes, a UNC path). 184 assertions pass on 5.1. The round trip also passes under PowerShell 7; that full run otherwise needs #6's harness fix.

🤖 Generated with Claude Code

HalRiveria and others added 2 commits October 28, 2026 03:19
.NET Framework's ProcessStartInfo has no ArgumentList, so every caller
hand-quoted paths into one Arguments string, which breaks on embedded
quotes and trailing backslashes. ConvertTo-PkArgumentString joins a
list of arguments using the C runtime's quoting rules. It's available
inside workers too. README examples use it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The round-trip test ignored csc.exe's result, so a failed compile ended
the harness with a 'could not start' error instead of a [FAIL] line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria
HalRiveria merged commit 17fdbdc into main Oct 28, 2026
1 check passed
@HalRiveria
HalRiveria deleted the feat/argument-quoting branch October 28, 2026 07:47
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.

2 participants