Ed Sabol suggested to Dan Smith,
EJS> As for blank lines at the end of the body, I think that can be solved by
EJS> changing
JDS> # Now recurse if there are any remaining lines.
JDS> :0
JDS> * REMAININGLINES ?? .
EJS> to
EJS> # Now recurse if there are any remaining lines.
EJS> :0
EJS> * REMAININGLINES ?? (.|$)
EJS> in the generic case, assuming one wants to preserve blank lines at the
EJS> end of the body. (I'm so used to using "VAR ?? ." to check to see
EJS> whether a variable is set or not, I forgot momentarily that "." won't
EJS> match newlines.)
If you use
* VAR ?? .
to check whether a variable is set or not, it will bite you hard some day.
Not only will it give a false negative if the variable contains only new-
lines; it will also be wrong about a null variable.
To check whether a variable is non-null, Ed's idea of
* VAR ?? (.|$)
will do, or also
* $ !${VAR:+!}
but neither is a way to check whether a variable is set or not, because each
treats a null variable the same as an unset one. This is the best way I know
to check whether a variable is set or not:
* $ !${VAR+!}