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?
source
share