Why doesn't “set -P” work after a pipe?

后端 未结 4 1817
予麋鹿
予麋鹿 2021-02-14 09:13
C:\\>type c:\\output.txt
abcd
C:\\>type c:\\output.txt | set /p V1=

C:\\>set
... A bunch of junk, NOT seeing \"V1\"

What happened? According

4条回答
  •  清酒与你
    2021-02-14 09:58

    The pipe seems to create a new CMD instance to carry out the next command that is receiving the pipe data. So when the pipe has concluded, that CMD instance exits and the variable is lost.

提交回复
热议问题