On Sat, Mar 11, 2017 at 5:45 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
* Whether or not you think it's important not to expand skipped variables, I think that it's critical that skipped backtick expressions not be executed.
[...]
I do not think that a skipped \if or \elif should evaluate its argument at all.
[...]
* I'm not on board with having a bad expression result in failing the \if or \elif altogether. It was stated several times upthread that that should be processed as though the result were "false", and I agree with that.
+1
Oddly, Corey was using you as support for this position...though without an actual quote:
"""
Tom was pretty adamant that invalid commands are not executed. So in a case
like this, with ON_ERROR_STOP off:
\if false
\echo 'a'
\elif true
\echo 'b'
\elif invalid
\echo 'c'
\endif
Both 'b' and 'c' should print, because "\elif invalid" should not execute.
The code I had before was simpler, but it missed that.
Robert made a comment somewhere along the line about users wanting to simply re-type the intended line if the "invalid" was interactive and due to a typo. That concern is pretty much limited to just the "\if" situation - if you typo an "\elif" block you can just type "\elif" again and begin yet another "\elif" block. I say we live with it and focus on the UX - if you type \if no matter what happens after you hit enter you are in a conditional block and will need to \endif at some point. Re-typing the correct \if command will just make you need another one of them.