Batch - why set / P behaves differently with | and with <

When reading stdin with set / P, it seems that when reading from a pipe, this does not work, and when reading from a redirect, it works fine. This is shown with the following lines:

D:\>echo 1 >f1

D:\>echo 2 >>f1

D:\>type f1
1
2

D:\>type f1 | (set line1=&set line2=&set /P line1=&set /P line2=&set line)
line1=1
line2=

D:\>(set line1=&set line2=&set /P line1=&set /P line2=&set line)<f1
line1=1
line2=2

D:\>

Why is line2 read in one case and not in another?

+3
source share
1 answer

Originally posted using MC ND in the comments.

by sending the same answer as this question, so the question does not count without an answer, the author of the question also confirms in the comments that MC ND's answer was correct, and that helped.

I think there is enough background, here is a comment as an answer.

. - MC ND 2 22:03

0

Source: https://habr.com/ru/post/1695651/


All Articles