I am seeing unexpected behavior from popd command where it runs fine, return 0 errorlevel, but then triggers conditional execution specified by || conditional execution operator. Here is a sample batch file:
@pushd || (@echo pushd failed with %errorlevel% & @goto Error)
@popd || (@echo popd failed with %errorlevel% & @goto Error)
:: ===== Success termination point =====
@echo SUCCESS!
@exit /b 0
:: ===== Failure termination point =====
:Error
@echo FAILURE
@exit /b 1
When I run it, I get the following output:
popd failed with errorlevel=0
FAILURE
Failure with errorlevel=0 is an oxymoron.
So basically, unless I am doing something wrong, || conditional execution operator is useless for checking the outcome of the popd command. This is bad, because || is used extensively to check for errors in concise and elegant way.
I have read popd command help here and here, but nothing is mentioned about this unexpected behavior.
I am running it on legitimately licensed Windows 10 IoT Enterprise LTSC, all current updates installed.
I do not see this unexpected behavior from pushd or any other internal or external command.
Does anyone know more than I do on this topic?