I'm running Emacs 25.2.2 on Ubuntu 17.10. Although my environment has TERM=xterm-256color, (getenv "TERM") returns dumb, which is incorrect.

Why does (getenv "TERM") return an incorrect value?

1 Answer 1


Quoting startup.el:

;; Subprocesses of Emacs do not have direct access to the terminal, so
;; unless told otherwise they should only assume a dumb terminal.
;; We are careful to do it late (after term-setup-hook), although the
;; new multi-tty code does not use $TERM any more there anyway.
(setenv "TERM" "dumb")

If Emacs didn't set TERM=dumb then every subprocess invocation would need to do so manually.

  • End-User Documentation (i.e., gnu.org/software/emacs/manual/html_node/emacs/index.html#Top) in section C.4 reads, "The environment is a feature of the operating system... Inside Emacs, the command M-x getenv reads the name of an environment variable, and prints its value in the echo area." The documentation specifically refers to $TERM. Thanks for the help.
    – TheGeeko61
    Commented Feb 4, 2018 at 11:24
  • 7
    You can use (getenv-internal "TERM" initial-environment) to get the original value of $TERM.
    – npostavs
    Commented Feb 4, 2018 at 13:11
  • But this interferes with 24-bit true color that needs a specific terminfo.
    – HappyFace
    Commented Sep 21, 2021 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.