It seems that -halt-on-error
will still pester you for input if you have -interaction
set to scrollmode
(default) or errorstopmode
. Therefore, -halt-on-error
by itself does not seem sufficient to avoid hangs in scripts.
I’ve not yet confirmed this, but I believe -interaction=nonstopmode
by itself is enough to prevent hangs. The only difference -halt-on-error
makes is that it will give up on the first error rather than keep trying for up to 100 errors.
Example:
$ echo '\input{nonexistentfile}' >bad.tex
$ tex -halt-on-error bad.tex
This is TeX, Version 3.14159265 (TeX Live 2016/Arch Linux) (preloaded format=tex)
(./bad.tex
! I can't find file `{nonexistentfile}'.
l.1 \input{nonexistentfile}
(Press Enter to retry, or Control-D to exit)
Please type another input file name: █