-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-AnsweredThe question is answered.The question is answered.
Description
Note: This is technically a breaking change; if it is deemed too risky, keep it on file for PowerShell vNext.
Currently, output-to-file cmdlets such as Out-File and Set-Content do support wildcard expression passed to their -Path parameter.
This behavior is problematic in two respects:
-
Overwriting existing files should be a very deliberate act; the use of wildcards to target whatever happens to match contradicts that.
-
The utility of targeting an output file implicitly by wildcard is very limited:
- If no existing file matches the wildcard expressions, an error occurs.
- If more than one file matches the wildcard expression, the behavior is inconsistent:
- With some cmdlets, an error occurs (e.g.,
Out-File,Export-FormatData- In other words: only if the wildcard expression happens to match one existing file does the operation succeed - at which point the clearer and safer choice is to target that file with a literal path.
- Other cmdlets (e.g.
Set-Content) output to all matching files, which is also problematic.
- With some cmdlets, an error occurs (e.g.,
Ergo: output-to-file cmdlets should treat -Path as an alias of -LiteralPath (similar to how -Path in New-Item is effectively -LiteralPath).
Environment data
Written as of:
PowerShell Core v6.0.2Metadata
Metadata
Assignees
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-AnsweredThe question is answered.The question is answered.