Subject: bug#76787: 31.0.50; Double backtrace in batch mode

From: Stefan Monnier <[email-masked]>
Date: Thu, 06 Mar 2025 12:23:15 -0500

Package: Emacs
Version: 31.0.50

Emacs in batch mode sometimes shows twice the same backtrace:

    % /usr/bin/emacs -Q --batch --eval '(setq debug-on-error t)' --eval '(error "foo")'                            
    
    Error: error ("foo")
      error("foo")
      eval((error "foo") t)
      command-line-1(("--eval" "(setq debug-on-error t)" "--eval" "(error \"foo\")"))
      command-line()
      normal-top-level()
    
    Debugger entered--Lisp error: (error "foo")
      error("foo")
      eval((error "foo") t)
      command-line-1(("--eval" "(setq debug-on-error t)" "--eval" "(error \"foo\")"))
      command-line()
      normal-top-level()
    
    %

I think I'm in part to blame for this one.  It seems that one of them
comes from the "normal" debugger and the other from
`debug-early--handler`.

        Stefan