Windows command interpreter: how to obtain exit code of first piped command

后端 未结 2 1623
悲哀的现实
悲哀的现实 2020-12-01 12:29

In the example provided below, I execute nmake and then redirect STDOUT/STDERR to tee, which then sends it to the screen, and also to a log file. The problem is that I\'m tr

2条回答
  •  一生所求
    2020-12-01 13:20

    There is a version of "tee" (called mtee => https://ritchielawrence.github.io/mtee/) that optionally adopts the exit code of the piped process. With that you could write

    nmake | mtee /E output.txt
    

提交回复
热议问题