Why don't Windows Shell (cmd.exe) builtin commands read from stdin?

允我心安 提交于 2020-01-06 16:18:10

问题


Why don't Windows Shell (cmd.exe) built-in commands read from stdin? (or so it seems)

Example:

echo bar | set /p foo=

回答1:


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?



来源:https://stackoverflow.com/questions/37804188/why-dont-windows-shell-cmd-exe-builtin-commands-read-from-stdin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!