Why does the Windows Command Prompt COPY command write error messages to STDOUT not STDERR?

0

Normally if you try to copy a file that does not exist you get an error message:

C:\temp>copy foo bar
The system cannot find the file specified.

I would expect that error message to be written to STDERR but it appears to be written to STDOUT:

C:\temp>copy foo bar >out

C:\temp>dir

 Directory of C:\temp

23/09/2019  16:18                44 out
               1 File(s)             44 bytes
               0 Dir(s)  885,229,346,816 bytes free

C:\temp>type out
The system cannot find the file specified.

The same apparently happens if you redirect STDERR separately from STDOUT

C:\temp>del out

C:\temp>copy foo bar 2>err >out

C:\temp>dir

 Directory of C:\temp

23/09/2019  16:10                 0 err
23/09/2019  16:10                44 out
               2 File(s)             44 bytes
               0 Dir(s)  885,226,635,264 bytes free

C:\temp>type out
The system cannot find the file specified.

I am using Windows 10

C:\temp>ver

Microsoft Windows [Version 10.0.18362.356]

Why does COPY not write error messages to STDERR? Where is this behaviour documented?

RedGrittyBrick

Posted 2019-09-23T15:26:12.533

Reputation: 70 632

This is not execution error. This is parameter error not relative to the copying process, which have not started yet. – Akina – 2019-09-23T15:54:50.213

1

@Akina: It's still an error and as such should go to stderr. In fact, it is exactly the kind of error that stderr was invented for.

– user1686 – 2019-09-23T17:30:36.937

@grawity Program author is the only who can decide what problem is error and what is not. But in this particular case %ERRORLEVEL% = 1 - so it is really programmer's mistake. – Akina – 2019-09-23T18:24:22.673

No answers