Repository navigation
Quote a list in Arguments, one argument per element - #34
Merged
Merged
Conversation
An array in a batch command's or dispatcher job's Arguments was joined with
spaces (or $OFS) and no quoting, so @('C:\My Files\a.png', 'out.jxl') reached
the program as three arguments. Start-PkProcess and
Invoke-PkProcessWithTimeout refused an array with a cryptic binding error but
still space-joined a List or ArrayList.
All four now take one string, used exactly as written, or a list, quoted the
way ConvertTo-PkArgumentString quotes it. A $null element is left out, an empty
string stays "", and a hashtable is refused with a clear message.
ConvertTo-PkArgumentString now accepts $null and leaves $null elements out. It
takes [object[]] instead of [string[]], because binding an array held in a
variable to [string[]] turned a $null element into '' before it could be
dropped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What was wrong
An array in a batch command's or dispatcher job's
Argumentswas joined with spaces (or$OFS) and no quoting, so@('C:\My Files\a.png', 'out.jxl')reached the program as three arguments.Start-PkProcessandInvoke-PkProcessWithTimeoutrefused an array withCannot convert value to type System.String, but still space-joined aListorArrayList.ConvertTo-PkArgumentString @('a', $null, 'b')threw, and with the array in a variable it passed the$nullon as"".What changed
ConvertTo-PkArgumentStringquotes it.$OFSno longer matters.$nullelement is left out; an empty string is still passed as"". A hashtable is refused withArguments must be one string or a list of arguments.ConvertTo-PkArgumentStringaccepts$nulland leaves$nullelements out. Its parameter is now[object[]]: binding an array held in a variable to[string[]]turned a$nullelement into''before the function could see it.StartFailureReportedamong its reserved keys.Behavior to note
A list whose elements were pre-quoted pieces of a command line, such as
@('"C:\My Files\a.png"', 'out.jxl'), used to work by accident. Each element is now one argument, so the quote characters reach the program. Pass such a command line as one string instead. A list with no spaces or quotes in it gives the same command line as before.Testing
Harness passes on Windows PowerShell 5.1 and PowerShell 7 (367 assertions, none skipped). The new section uses a compiled program that prints each argument it gets; 10 of its assertions failed before the change, and the run stopped at the
$nullcase.🤖 Generated with Claude Code