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:
@echo off
goto main
:main
setlocal
echo 111 | (set /p readvalue= & set readvalue)
echo 123 | (set /p readvaluebash= & 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
I always get the yes result. Anyone know my mistake here? Thanks in advance!