0

I want TeX to terminate on any error, because I only care about the first error and so that it finishes faster.

Unfortunately, if I use either -interaction=errorstopmode (and run with </dev/null) or -halt-on-error, any \show (or expl3's \tl_show:n command terminates the program.

Is there any way to stop TeX on first error, but don't stop on debug print commands?

user202729
  • 7,143

1 Answers1

3

The best approach would be to turn locally to \nonstopmode and get back to \errorstopmode afterwards. With the manual overhead to always insert that before and after \show you're practically done and it works with every token:

\nonstopmode
\show{
\show}
\show\stop
\show\show
\errorstopmode

With the restriction to N-type arguments you could also automate this:

\newcommand\shownonstop[1]
  {%
    \nonstopmode
    \show#1%
    \errorstopmode
  }

If you don't want to accidentally change modes if you're not currently in \errorstopmode you could take a look at how to get the current interaction mode.

Both of the above would still result in a non-zero return value of TeX (so be considered a "failed" run).

Another possibility would be to reimplement the functionality yourself. A simple implementation would be

\newcommand\shownonstop[1]{\typeout{\string#1: \meaning#1}}

If you want to get the exact same formatting we have to invest a bit more work:

\ExplSyntaxOn
\cs_new_protected:Npn \shownonstop #1
  {
    \iow_term:x
      {
        >~
        \bool_lazy_or:nnTF
          { \token_if_cs_p:N #1 }
          { \token_if_macro_p:N #1 }
          {
            \token_to_str:N #1 =
            \token_if_primitive:NTF #1
              { \token_to_meaning:N #1 }
              { \exp_after:wN \my_shownonstop_macro:w \cs_meaning:N #1 \s_stop }
          }
          { \token_to_meaning:N #1 }
        .
      }
  }
\exp_last_unbraced:NNNNo
\cs_new:Npn \my_shownonstop_macro:w #1 \c_colon_str #2 \s_stop { #1: ^^J #2 }
\ExplSyntaxOff
Skillmon
  • 60,462