公告
财富商城
积分规则
提问
发文
2019-09-09 22:14发布
你好瞎i
Why don't Windows Shell (cmd.exe) built-in commands read from stdin? (or so it seems)
Example:
echo bar | set /p foo=
SET /P does read the input from the pipe, but it doesn't do any good because both sides of the pipe are executed within new cmd.exe processes. So the newly defined variable is lost once the pipe sub-processes terminate.
For more information, see the selected answer to the Stack Overflow question - Why does delayed expansion fail when inside a piped block of code?
最多设置5个标签!
SET /P does read the input from the pipe, but it doesn't do any good because both sides of the pipe are executed within new cmd.exe processes. So the newly defined variable is lost once the pipe sub-processes terminate.
For more information, see the selected answer to the Stack Overflow question - Why does delayed expansion fail when inside a piped block of code?