Skip to content

Quote a list in Arguments, one argument per element - #34

Merged
HalRiveria-Bot merged 2 commits into
mainfrom
fix/array-arguments
Nov 3, 2026
Merged

HalRiveria-Bot merged 2 commits into
mainfrom
fix/array-arguments

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

What was wrong

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 Cannot convert value to type System.String, but still space-joined a List or ArrayList.

ConvertTo-PkArgumentString @('a', $null, 'b') threw, and with the array in a variable it passed the $null on as "".

What changed

  • All four entry points take one string, used exactly as written, or a list, quoted the way ConvertTo-PkArgumentString quotes it. $OFS no longer matters.
  • A $null element is left out; an empty string is still passed as "". A hashtable is refused with Arguments must be one string or a list of arguments.
  • ConvertTo-PkArgumentString accepts $null and leaves $null elements out. Its parameter is now [object[]]: binding an array held in a variable to [string[]] turned a $null element into '' before the function could see it.
  • README and help text describe the list form. The dispatcher help now also lists StartFailureReported among 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 $null case.

🤖 Generated with Claude Code

HalRiveria and others added 2 commits November 2, 2026 21:27
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>
@HalRiveria-Bot
HalRiveria-Bot merged commit 38f68ef into main Nov 3, 2026
2 checks passed
@HalRiveria-Bot
HalRiveria-Bot deleted the fix/array-arguments branch November 3, 2026 02:33
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