<div dir="ltr"><div><div><div><div>> to my dismay, xelatex and lualatex seem to follow suit regarding missing
 \fi's or missing \endgroup's not changing exit status from 0.<br><br></div>Like most programs they give 0 if the program only made warnings and not errors.<br><br></div>It's easy enough to make these things an error via macros, in which case the exit status is non zero.<br><br></div>For example the following plain tex with any engine supporting etex extensions:<br><br><br>\outer\def\bye{\par\vfill\supereject<br>\ifnum\currentiflevel>1<br>\errmessage{if nesting is \the\numexpr\currentiflevel-1\relax}%<br>\fi<br>\end}<br><br><br><br>\if aa %\fi<br>\bye<br><br><br><br></div>will run without warning or error if you uncomment the \fi but as it is you get an error status of 1 as shown by<br><br>$ pdftex --interaction=scrollmode er.tex; echo exit status = $?<br>This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdftex)<br> restricted \write18 enabled.<br>entering extended mode<br>(./er.tex<br>! if nesting is 1.<br>\bye ...s \the \numexpr \currentiflevel -1\relax }<br>                                                  \fi \end <br>l.11 \bye<br>         <br> )<br>(\end occurred when \if on line 10 was incomplete)<br>(see the transcript file for additional information)<br>No pages of output.<br>Transcript written on er.log.<br>exit status = 1<br><br><br><br></div>