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
Join-String -InputObject 1,2,3 result is not equal to 1,2,3 | Join-String result. #8610
Breaking-Changebreaking change that may affect usersIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.WG-Cmdletsgeneral cmdlet issues
That is, the only operation being performed is the stringification of the input array (implicit joining with $OFS) during parameter binding - Join-String itself is then a no-op, given that it then receives a single input string; in other words: there's nothing left to join.
As for how to implement the proposed change: PetSerAl has since shown that switching to PSObject[] in an effort to treat -InputObjectarguments the same as PSObject-based -InputObjectpipeline input doesn't work in all cases: #4242 (comment)
As for whether to implement the change at all:
We need to decide whether we even want to support -InputObject argument / pipeline equivalence for collection-enumerating cmdlets such as Join-String (my vote: yes), or whether we should treat -InputObject simply as an auxiliary parameter that facilitates pipeline input but is not to be used directly with arguments - see #4242 (comment)
If the latter, Join-String -InputObject 1,2,3 would then by design not be (meaningfully) supported, and there'd be nothing to change.
I think that from a semantic perspective, having -InputObject be primarily an implementation detail of standard pipeline support isn't necessarily wrong per se? I think it would be better if there were some way via attribute or some such to denote a parameter as Pipeline-Only such that it wouldn't appear in tab completions or be usable for input directly; in this way we could avoid some of the confusion perhaps?
But whatever option ultimately wins out here... we should also consider that while there is a mostly consistent implementation amongst standard cmdlets, it's not completely consistent, which is a problem: without a consistent and clear example to follow, third-party cmdlets tend to pick and choose whatever they feel is most appropriate more often than not, which seems to lead to less consistent practices in the wider PowerShell community in this regard.
As a result, I think that opting to change anything here will only have a meaningful impact if we can decide on and then actually enact a consistent implementation across all the standard PowerShell cmdlets.
Excellent points, Rain Sallow (/u/ta11ow) (@vexx32) - I'm hoping that a decision on a consistent cross-cmdlet approach will come as a result of the discussion in #4242.
I think it would be better if there were some way via attribute or some such to denote a parameter as Pipeline-Only such that it wouldn't appear in tab completions or be usable for input directly
Just some thoughts: It's useful to use -InputObject directly in case that you already have the collection object handy and want to avoid the unnecessary pipeline binding overhead.
In the case of calling a cmdlet in C#, disallowing the use of -InputObject directly would mean that you have to pass in the collection object by powershell.Invoke(myCollection)
Dongbo Wang (@daxian-dbw): The performance argument is also mentioned in #4242 (comment) and, at the risk of talking myself hoarse, can we please continue the conversation there (#4242)? (I also encourage you to clarify your C# argument - there.)
Breaking-Changebreaking change that may affect usersIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.WG-Cmdletsgeneral cmdlet issues
Activity
mklement0 commentedon Jan 9, 2019
Cool, thanks for fixing this; for the general issue with scalar
-InputObjectparameters, see #4242.mklement0 commentedon Jan 9, 2019
Sergey Vasin (@sethvs), in the implementation it may be better to leave
-InputObjectas aPSObjectrather than making itPSObject[], for efficiency - please see the discussion with Rain Sallow (/u/ta11ow) (@vexx32) starting here.sethvs commentedon Jan 9, 2019
Michael Klement (@mklement0) Thanks. I'll leave the decision to maintainers.
BrucePay commentedon Jan 11, 2019
Note that this is a breaking change.
mklement0 commentedon Jan 11, 2019
Bruce Payette (@BrucePay): It's highly likely that this is a Bucket 3: Unlikely Grey Area change:
is currently effectively the same as:
That is, the only operation being performed is the stringification of the input array (implicit joining with
$OFS) during parameter binding -Join-Stringitself is then a no-op, given that it then receives a single input string; in other words: there's nothing left to join.sethvs commentedon Jan 14, 2019
Bruce Payette (@BrucePay) The
Join-Stringcmdlet has been released in preview.3 only and not in official releases.mklement0 commentedon Jan 14, 2019
Good point, Sergey Vasin (@sethvs).
As for how to implement the proposed change:
PetSerAl has since shown that switching to
PSObject[]in an effort to treat-InputObjectarguments the same asPSObject-based-InputObjectpipeline input doesn't work in all cases: #4242 (comment)As for whether to implement the change at all:
We need to decide whether we even want to support
-InputObjectargument / pipeline equivalence for collection-enumerating cmdlets such asJoin-String(my vote: yes), or whether we should treat-InputObjectsimply as an auxiliary parameter that facilitates pipeline input but is not to be used directly with arguments - see #4242 (comment)If the latter,
Join-String -InputObject 1,2,3would then by design not be (meaningfully) supported, and there'd be nothing to change.vexx32 commentedon Jan 14, 2019
🤔
I think that from a semantic perspective, having
-InputObjectbe primarily an implementation detail of standard pipeline support isn't necessarily wrong per se? I think it would be better if there were some way via attribute or some such to denote a parameter asPipeline-Onlysuch that it wouldn't appear in tab completions or be usable for input directly; in this way we could avoid some of the confusion perhaps?But whatever option ultimately wins out here... we should also consider that while there is a mostly consistent implementation amongst standard cmdlets, it's not completely consistent, which is a problem: without a consistent and clear example to follow, third-party cmdlets tend to pick and choose whatever they feel is most appropriate more often than not, which seems to lead to less consistent practices in the wider PowerShell community in this regard.
As a result, I think that opting to change anything here will only have a meaningful impact if we can decide on and then actually enact a consistent implementation across all the standard PowerShell cmdlets.
mklement0 commentedon Jan 14, 2019
Excellent points, Rain Sallow (/u/ta11ow) (@vexx32) - I'm hoping that a decision on a consistent cross-cmdlet approach will come as a result of the discussion in #4242.
daxian-dbw commentedon Jan 23, 2019
Just some thoughts: It's useful to use
-InputObjectdirectly in case that you already have the collection object handy and want to avoid the unnecessary pipeline binding overhead.In the case of calling a cmdlet in C#, disallowing the use of
-InputObjectdirectly would mean that you have to pass in the collection object bypowershell.Invoke(myCollection)mklement0 commentedon Jan 24, 2019
Dongbo Wang (@daxian-dbw): The performance argument is also mentioned in #4242 (comment) and, at the risk of talking myself hoarse, can we please continue the conversation there (#4242)? (I also encourage you to clarify your C# argument - there.)
Make `Join-String -InputObject 1,2,3` result equal to `1,2,3 | Join-S…
Make `Join-String -InputObject 1,2,3` result equal to `1,2,3 | Join-S…