title: Batch: Pipe command output to variable and compare
body: <p>I try to pipe my command output to variables and then compare if those variables have the same value. However it always return both variables have same value(even though it is not). Below is my code:</p>
  
  <pre><code>@echo off
  goto main
  
  :main
  setlocal
  
  echo 111 | (set /p readvalue= &amp; set readvalue)
  echo 123 | (set /p readvaluebash= &amp; set readvaluebash)
  if "%readvalue%"=="%readvaluebash%" goto valid
  if NOT "%readvalue%"=="%readvaluebash%" goto invalid
  
  :valid
  echo yes
  pause
  goto finish
  
  :invalid
  echo no
  pause
  goto finish
  
  
  :finish
  endlocal
  </code></pre>
  
  <p>I always get the <code>yes</code> result. Anyone know my mistake here? Thanks in advance!</p>