Subject: bug#16859: tty-setup-hook can run twice

From: Glenn Morris <[email-masked]>
Date: Sun, 23 Feb 2014 20:39:24 -0500

Package: emacs
Version: 24.3.50

Current trunk on GNU/Linux.
I don't know if this matters, but tty-setup-hook can run twice.

>From an xterm:

export TERM=xterm
export COLORTERM=rxvt

cat <<EOF >| /tmp/.emacs
(add-hook 'tty-setup-hook (lambda () (message "hi")))
EOF

HOME=/tmp ./src/emacs -nw
C-h e
  -> hi [2 times]

This is because tty-run-terminal-initialization runs terminal-init-xterm,
which in this case calls tty-run-terminal-initialization again with type
"rxvt".

Since several of the other init functions in term/ run
tty-run-terminal-initialization, this could happen with other terminal
types as well.