if (false) echo FALSE # This truth value will be used by ifnot
if (true) echo TRUE
if not echo NOT TRUE
This erroneously outputs NOT TRUE.
I should mention that this is a rather serious bug, if you're using if not. It can make the logic of a script completely wrong if you are using a simple if without else or if not early in the script, and later use if-if not, where the if not will use the truth value of the earlier if and not the preceding one.
if_last should be updated after possibly nested if-ifnots are executed, and it should be set to the truth value of an else-less if, or to if_nothing if the if had an else.
This will trigger the error "if not must follow if" whenever ifnot is used after an else (or an ifnot), but it will not trigger an error for the following:
if (false) echo FALSE
echo ALWAYS
if not echo NOT FALSE
I don't think this necessarily should be considered an error. Right now however the parser does, although it only detects in in lines, so the following will trigger the "if not must follow if" error:
if (false) echo FALSE; echo ALWAYS; if not echo NOT FALSE
Example:
This erroneously outputs NOT TRUE.
I should mention that this is a rather serious bug, if you're using
if not
. It can make the logic of a script completely wrong if you are using a simpleif
withoutelse
orif not
early in the script, and later useif
-if not
, where theif not
will use the truth value of the earlier if and not the preceding one.Here's a patch that tests for this in trip.rc
And here's a fix:
if_last should be updated after possibly nested if-ifnots are executed, and it should be set to the truth value of an else-less if, or to if_nothing if the if had an else.
This will trigger the error "if not must follow if" whenever ifnot is used after an else (or an ifnot), but it will not trigger an error for the following:
I don't think this necessarily should be considered an error. Right now however the parser does, although it only detects in in lines, so the following will trigger the "if not must follow if" error:
but should it...?