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
Introduce a more descriptive parameter alias for Get-Content -Raw #7715
Committee-ReviewedPS-Committee has reviewed this and made a decisionIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdletsgeneral cmdlet issues
I, personally, don't have a problem with it. I know Get-Content always returns an array of strings (at least for text files), so 'raw' to me means just the raw text, without any splitting.
The parameter description in the context of the filesystem-provider-specific help topic is passable, but can be improved: MicrosoftDocs/PowerShell-Docs#2697
In the provider-independent help topic - the one that's discoverable far more easily - the generic description is downright misleading:
This parameter is not supported by any providers that are installed with PowerShell.
However, that, and the difficulty in locating the provider-specific help topics, are fundamental, structural problems not specific to -Raw that will go away (hopefully soon), according to MicrosoftDocs/PowerShell-Docs#1101 (comment):
Yeah, the provider-specific help is a work-in-progress. Long story but we are working on it. The goal is to wrap all of that content into the provider-affected cmdlets and get rid of the provider-specific docs.
The typical connotation of raw in the context of files is uninterpreted (undecoded) data ("raw bytes").
(As such, you could argue that -Raw should be an alias of -AsByteStream, which is the closest thing PowerShell has to passing bytes through.)
By contrast, -Rawdoes perform interpretation / decoding, namely decoding the file's bytes to strings based on the file's assumed or explicitly specified character encoding, just as without-Raw.
The only thing that -Raw changes is the partitioning of the data read, so that is what the switch name should reflect, hence my suggestion -Whole
Michael Klement (@mklement0) "Raw" in this context means, "undecorated", "not cooked", etc. This is the parameter that the PowerShell team has chosen for this purpose. We could have chosen a different parameter but we did not. Some people will complain that it doesn't mean the right thing to them. That's fine. No matter what we choose, this will always be the case because different people have different perspectives. In PowerShell we try to choose a single term and apply it consistently so that, even if it does not seem intuitive to a person, they only have to learn it once. Sometimes we choose a sub-optimal term but we live with it because you should only have to learn something once. Very rarely, we try and "fix" things like we did with $_ and $PSItem. This sounded good because new users didn't "get" $_. So we added $PSItem as being easier to understand. The feedback we received from people who teach PowerShell is that rather than helping, having to teach two terms made it worse/more confusing for people trying to learn PowerShell.
"Raw" in this context means, "undecorated", "not cooked", etc. This is the parameter that the PowerShell team has chosen for this purpose.
That would be fine, except, as previously stated, that is not what -Raw actually does:
It still decorates its (one) output string.
All it does is change the units of data being read from lines (by default) to the whole file.
In other words:
The reality of the switch does not align with the stated purpose and this regrettable precedent prevents meaningful use of -Raw in other contexts in alignment with its true purpose.
One way of dealing with a misnomer is to provide a more sensibly named alias and to deprecate / deemphasize the old name.
In other words: The intent is for the new name to in effect supersede the old one, so the $_ / $PSItem comparison doesn't apply (given that neither is deprecated).
Yes, there will be confusion for a while, but over time the sensible name will (hopefully) prevail.
The reality of the switch does not align with the stated purpose and this regrettable precedent prevents meaningful use of -Raw in other contexts in alignment with its true purpose.
As I said, people will have different opinions on how whatever term we choose should be interpreted. Breaking the text into strings can be viewed as "cooking" and thus -Raw should return a single string.
One way of dealing with a misnomer is to provide a more sensibly named alias and to deprecated / deemphasize the old name.
We've never actually deprecated anything and aren't likely to do so anytime soon.
We have too many such discussions without a conclusion.
I think PowerShell Committee can consider this - should we replace -Raw with -Whole (as alias) or Won't fix?
Ilya (@iSazonov): To be clear: -Bare is not the right (alias) name for the current -Raw switch. As proposed in the OP, something like -Whole would make sense.
Deprecating -Raw in favor of something more descriptive such as -Whole would clear the way for use of -Bare with the semantics described above, and -Bare would then become a new switch in the context of Get-Content, for requesting undecorated lines (strings without ETS properties), as suggested in #7537
-RootModule
[...]
In Windows PowerShell 2.0, this key was called ModuleToProcess.
And yet it's still there in version 6, both as a parameter alias and mentioned in the .psd1 file:
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess# NestedModules = @()
Deprecated implies "don't use, will be removed at some future time". We don't do this. What we do is deemphasize things.
In this specific case, "RootModule" is semantically much stronger than "ModuleToProcess". There is a clear semantic advantage in using one term over the other whereas -Base and -Raw - are almost synonyms (at least in this context).
You yourself noticed the problem with -Raw int the
Yes :-) I had intended/expected that -Raw should write a stream of undecorated strings into the pipeline however the developer who actually implemented it chose a different interpretation.
Deprecating -Raw in favor of something more descriptive such as -Whole would clear the way for use of -Bare with the semantics described above, and -Bare
Again, -Raw isn't going away so you'd have a cmdlet with both -Raw and -Bare which is pretty confusing (unless you make one an alias of the other in which case the semantic doesn't change.). Also the current -Raw semantic can be "fixed" by adding -Stream as in Out-String -Stream so you'd do gc -raw -stream foo.txt.
Ilya (@iSazonov) The committee doesn't need to be involved in a parameter change but if we do want to propose a new normative pattern, it should go through the RFC process.
I would be in favour of leaving -Raw as an alias and changing the name to -Bare
I'd potentially be in favour of using -Bytes as a switch to specify to retrieve the bytes in the file per line, which could operate hand in hand with a -Whole switch to read the bytes of the entire file (or just flat out always read all bytes in the file indiscriminately).
-Bare is not different enough from -Raw to communicate functional differences.
Agreed - but that's precisely why I suggested introducing -Whole and de-emphasizing -Raw.
-Bare wouldn't just benefit Get-Content, but, as I've proposed above, could become a general pattern for all cmdlets where undecorated / unwrapped output is desirable on an opt-in basis.
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
Committee-ReviewedPS-Committee has reviewed this and made a decisionIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdletsgeneral cmdlet issues
Activity
iSazonov commentedon Sep 6, 2018
The parameter is not documented well :-)
MartinSGill commentedon Sep 6, 2018
I, personally, don't have a problem with it. I know Get-Content always returns an array of strings (at least for text files), so 'raw' to me means just the raw text, without any splitting.
mklement0 commentedon Sep 6, 2018
Ilya (@iSazonov) : Good point, but that's a separate issue:
The parameter description in the context of the filesystem-provider-specific help topic is passable, but can be improved: MicrosoftDocs/PowerShell-Docs#2697
In the provider-independent help topic - the one that's discoverable far more easily - the generic description is downright misleading:
However, that, and the difficulty in locating the provider-specific help topics, are fundamental, structural problems not specific to
-Rawthat will go away (hopefully soon), according to MicrosoftDocs/PowerShell-Docs#1101 (comment):mklement0 commentedon Sep 6, 2018
Martin Gill (@MartinSGill):
The typical connotation of raw in the context of files is uninterpreted (undecoded) data ("raw bytes").
(As such, you could argue that
-Rawshould be an alias of-AsByteStream, which is the closest thing PowerShell has to passing bytes through.)By contrast,
-Rawdoes perform interpretation / decoding, namely decoding the file's bytes to strings based on the file's assumed or explicitly specified character encoding, just as without-Raw.The only thing that
-Rawchanges is the partitioning of the data read, so that is what the switch name should reflect, hence my suggestion-WholeBrucePay commentedon Sep 6, 2018
Michael Klement (@mklement0) "Raw" in this context means, "undecorated", "not cooked", etc. This is the parameter that the PowerShell team has chosen for this purpose. We could have chosen a different parameter but we did not. Some people will complain that it doesn't mean the right thing to them. That's fine. No matter what we choose, this will always be the case because different people have different perspectives. In PowerShell we try to choose a single term and apply it consistently so that, even if it does not seem intuitive to a person, they only have to learn it once. Sometimes we choose a sub-optimal term but we live with it because you should only have to learn something once. Very rarely, we try and "fix" things like we did with
$_and$PSItem. This sounded good because new users didn't "get"$_. So we added$PSItemas being easier to understand. The feedback we received from people who teach PowerShell is that rather than helping, having to teach two terms made it worse/more confusing for people trying to learn PowerShell.mklement0 commentedon Sep 6, 2018
Bruce Payette (@BrucePay):
That would be fine, except, as previously stated, that is not what
-Rawactually does:In other words:
The reality of the switch does not align with the stated purpose and this regrettable precedent prevents meaningful use of
-Rawin other contexts in alignment with its true purpose.One way of dealing with a misnomer is to provide a more sensibly named alias and to deprecate / deemphasize the old name.
In other words: The intent is for the new name to in effect supersede the old one, so the
$_/$PSItemcomparison doesn't apply (given that neither is deprecated).Yes, there will be confusion for a while, but over time the sensible name will (hopefully) prevail.
BrucePay commentedon Sep 6, 2018
As I said, people will have different opinions on how whatever term we choose should be interpreted. Breaking the text into strings can be viewed as "cooking" and thus
-Rawshould return a single string.We've never actually deprecated anything and aren't likely to do so anytime soon.
mklement0 commentedon Sep 7, 2018
That genie is already out of the bottle:
You yourself noticed the problem with
-Rawint the context of #7537: #7537 (comment)Since this discussion has now broadened in scope, let me reiterate and expand on what I proposed as an aside in #7713:
Retire the skunked
-Raw, as proposed by this issue.Introduce a general-purpose
-Bareswitch with the following, cross-cmdlet semantics:Output "bare" objects that are:
Get-Content, for instance (Get-Content is slow on large text files. Could it have a parameter to speed it up by not adding NoteProperties? #7537) and as a possible solution to ConvertTo-Json: unexpected behavior with objects that have ETS properties (NoteProperty, ScriptProperty) #5797)MatchInfoinstances bySelect-String(Add a switch to Select-String that makes it return just strings for convenience and performance #7713))iSazonov commentedon Sep 7, 2018
We have too many such discussions without a conclusion.
I think PowerShell Committee can consider this - should we replace
-Rawwith-Whole(as alias) or Won't fix?mklement0 commentedon Sep 7, 2018
Ilya (@iSazonov): To be clear:
-Bareis not the right (alias) name for the current-Rawswitch. As proposed in the OP, something like-Wholewould make sense.Deprecating
-Rawin favor of something more descriptive such as-Wholewould clear the way for use of-Barewith the semantics described above, and-Barewould then become a new switch in the context ofGet-Content, for requesting undecorated lines (strings without ETS properties), as suggested in #7537BrucePay commentedon Sep 7, 2018
Michael Klement (@mklement0)
And yet it's still there in version 6, both as a parameter alias and mentioned in the .psd1 file:
Deprecated implies "don't use, will be removed at some future time". We don't do this. What we do is deemphasize things.
In this specific case, "RootModule" is semantically much stronger than "ModuleToProcess". There is a clear semantic advantage in using one term over the other whereas
-Baseand-Raw- are almost synonyms (at least in this context).Yes :-) I had intended/expected that
-Rawshould write a stream of undecorated strings into the pipeline however the developer who actually implemented it chose a different interpretation.Again,
-Rawisn't going away so you'd have a cmdlet with both-Rawand-Barewhich is pretty confusing (unless you make one an alias of the other in which case the semantic doesn't change.). Also the current-Rawsemantic can be "fixed" by adding-Streamas inOut-String -Streamso you'd dogc -raw -stream foo.txt.Ilya (@iSazonov) The committee doesn't need to be involved in a parameter change but if we do want to propose a new normative pattern, it should go through the RFC process.
vexx32 commentedon Sep 7, 2018
I would be in favour of leaving
-Rawas an alias and changing the name to-BareI'd potentially be in favour of using
-Bytesas a switch to specify to retrieve the bytes in the file per line, which could operate hand in hand with a-Wholeswitch to read the bytes of the entire file (or just flat out always read all bytes in the file indiscriminately).4 remaining items
mklement0 commentedon Sep 19, 2018
Steve Lee (@SteveL-MSFT)
Agreed - but that's precisely why I suggested introducing
-Wholeand de-emphasizing-Raw.-Barewouldn't just benefitGet-Content, but, as I've proposed above, could become a general pattern for all cmdlets where undecorated / unwrapped output is desirable on an opt-in basis.iSazonov commentedon Sep 20, 2018
Michael Klement (@mklement0) It make sense to move the Bare proposal in new issue. It would be a new common parameter.
mklement0 commentedon Sep 24, 2018
Good idea, Ilya (@iSazonov) - please see #7855
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.