為什麼 Windows 命令提示字元 COPY 命令將錯誤訊息寫入 STDOUT 而不是 STDERR?

為什麼 Windows 命令提示字元 COPY 命令將錯誤訊息寫入 STDOUT 而不是 STDERR?

通常,如果您嘗試複製不存在的文件,您會收到錯誤訊息:

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

我希望錯誤訊息被寫入 STDERR,但它似乎被寫入 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.

如果您將 STDERR 與 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.

我使用的是 Windows 10

C:\temp>ver

Microsoft Windows [Version 10.0.18362.356]

為什麼 COPY 不將錯誤訊息寫入 STDERR?此行為記錄在哪裡?

相關內容