I don't have the ASDF environment variable defined, fine.
This is expected.
Code: Select all
C:\Users\username>set | find /i "ASDF"
This is expected.
Code: Select all
C:\Users\username>IF "%ASDF%"=="" (ECHO A) ELSE ECHO B
B
This is expected
Code: Select all
C:\Users\username>ECHO "%ASDF%"
"%ASDF%"
Code: Select all
C:\Users\username>type ffr.bat <ENTER>
@ECHO OFF
IF "%ASDF%"=="" GOTO lab1 ELSE GOTO lab2
:lab1
echo lab1
goto end
:lab2
echo lab2
:end
This is not expected. Why is the IF statement printing the case as if the condition is True?
C:\Users\username>ffr <ENTER>
lab1
And that's when done from a Batch file.
Then I try this test.. I do not see why it prints neither!! Surely either the IF clause is true or the ELSE clause is true!
It doesn't even break and print "A ELSE ECHO B". It just prints nothing!
Code: Select all
C:\Users\username>IF "%ASDF%"=="" ECHO A ELSE ECHO B
I don't see why this one line IF 4==4 requires parentheses
whereas the IF in the batch file.. The IF in the batch file I notice works
whether I do IF "%ASDF%"=="" (GOTO lab1) ELSE GOTO lab2
or IF "%ASDF%"=="" GOTO lab1 ELSE GOTO lab2
Code: Select all
C:\>IF 4==4 (ECHO A) ELSE ECHO B
A
C:\>IF "4"=="4" ECHO A ELSE ECHO B
A ELSE ECHO B
C:\>IF 4==4 ECHO A ELSE ECHO B
A ELSE ECHO B