为什么不“设置-P"?管后工作? [英] Why doesn't "set -P" work after a pipe?

查看:66
本文介绍了为什么不“设置-P"?管后工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C:\>type c:\output.txt
abcd
C:\>type c:\output.txt | set /p V1=

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

发生了什么事?根据我看到的所有SET文档,应该从上面为%V1%分配一个值"abcd",不是吗?

What happened? According to all documentation for SET I've seen, %V1% should have been assigned a value of "abcd" from the above, no?

如果有问题,我正在使用Windows XP Pro SP3.

I'm on Windows XP Pro, SP3 if it matters.

推荐答案

管道似乎创建了一个新的CMD实例,以执行下一个接收管道数据的命令.因此,当管道结束时,该CMD实例将退出并且该变量将丢失.

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.

这篇关于为什么不“设置-P"?管后工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆