You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CLI: -File-based / shebang-based invocations break with the end-of-parameters token, -- #20208
--, the (somewhat confusingly named) end-of-parameters token, signals the end of named arguments and treats all remaining token as positional arguments.
This mechanism is broken when calling via pwsh -File, which also happens implicitly when you call a shebang line-based PowerShells script (that doesn't have a .ps1 extension).
The -- is mistakenly interpreted as a parameter without a name.
# On Unix:# Create a simple shebang-based script.@'#!/usr/bin/env pwsh[CmdletBinding()]param( $a, [Parameter(ValueFromRemainingArguments)] $rest)"`$a: $a""`$rest: $rest"'@> tmpscript
chmod a+x tmpscript
# Invoke as stand-alone executable via the shebang line
./tmpscript -a one ---a other stuff
# Invoke explicitly via pwsh -File
pwsh -File ./tmpscript -a one ---a other stuff
Expected behavior
$a: one$rest: -a other stuff
That is, only one should bind to -a, with all arguments following -- binding to -rest, and the -- itself should be removed.
Actual behavior
Both calls fail with:
: Parameter cannot be processed because the parameter name '' is ambiguous. [...]
That is, -- was misinterpreted as a reference to a parameter without a name.
If you were to rename tmpscript to tmpscript.ps1 and invoke it in-process, the behavior would be as expected.
Error details
No response
Environment data
PowerShell 7.4.0-preview.5 on Unix-like platforms.
Activity