Why no error message?

May 20, 2008
12,171
133
Syracuse, NY, USA
Why doesn't the second command below produce an error message?
Code:
v:\> echo %zzzz
ECHO is OFF

v:\> if %zzzz LT 0 echo yes
yes

v:\> if LT 0 echo yes
Usage : IF [/I] [NOT] condition [.AND. | .OR. | .XOR. [NOT] condition ...] command
 
May 20, 2008
12,171
133
Syracuse, NY, USA
The IF %zzzz variable isn't expanded until the IF command runs. So it is *not* equivalent to "if LT 0"; it's equivalent to "IF (empty arg) LT 0".
I see that now. It's the same for IFF (and different for @IF). A long time ago I got into the habit of quoting (or somehow prefixing/postfixing the args to binary operators). Without thinking much about it lately, I figured that was in case they were empty. But empty isn't mush of a problem. Hmmm!
 

Similar threads