Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

">" creates files, even on terminating errors #10154

Closed
jszabo98 opened this issue Jul 14, 2019 · 2 comments
Closed

">" creates files, even on terminating errors #10154

jszabo98 opened this issue Jul 14, 2019 · 2 comments
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a Resolution-Answered The question is answered.

Comments

@jszabo98
Copy link

jszabo98 commented Jul 14, 2019

">" (but not | out-file) creates files, even when the command has a terminating error. (I was helping a newbie with > vs -gt.)

Steps to reproduce

PS /Users/js> try { 1 | Where $_ > 1  } catch { 'yes' } 

PS /Users/js> get-item 1

Expected behavior

yes

get-item : Cannot find path '/Users/js/1' because it does not exist.
At line:1 char:1
+ get-item 1
+ ~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (/Users/js/1:String) [Get-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand
 

Actual behavior

yes                           

    Directory: /Users/js

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-----           7/14/2019  7:01 PM              0 1

Environment data

Name                           Value
----                           -----
PSVersion                      6.2.0
PSEdition                      Core
GitCommitId                    6.2.0
OS                             Darwin 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 21 20:07:39 PDT 2018; root:xnu-3789.73.14~1/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
@jszabo98 jszabo98 added the Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a label Jul 14, 2019
@iSazonov
Copy link
Collaborator

It is "by design". Redirection is compiled as Out-File cmdlet, then engine execute begin blocks for every cmdlet in the pipeline and the file is created in begin block of Out-File cmdlet.

@iSazonov iSazonov added the Resolution-Answered The question is answered. label Jul 15, 2019
@ghost
Copy link

ghost commented Jul 16, 2019

This issue has been marked as answered and has not had any activity for 1 day. It has been closed for housekeeping purposes.

@ghost ghost closed this as completed Jul 16, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a Resolution-Answered The question is answered.
Projects
None yet
Development

No branches or pull requests

2 participants