1

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?

5

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 Feb 4 '18 at 11:24
  • 2
    You can use (getenv-internal "TERM" initial-environment) to get the original value of $TERM. – npostavs Feb 4 '18 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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