Function: term-exec-1

term-exec-1 is a byte-compiled function defined in term.el.gz.

Signature

(term-exec-1 NAME BUFFER COMMAND SWITCHES)

Source Code

;; Defined in /usr/src/emacs/lisp/term.el.gz
;; This auxiliary function cranks up the process for term-exec in
;; the appropriate environment.

(defun term-exec-1 (name buffer command switches)
  ;; We need to do an extra (fork-less) exec to run stty.
  ;; (This would not be needed if we had suitable Emacs primitives.)
  ;; The 'if ...; then shift; fi' hack is because Bourne shell
  ;; loses one arg when called with -c, and newer shells (bash,  ksh) don't.
  ;; Thus we add an extra dummy argument "..", and then remove it.
  (let ((process-environment
	 (nconc
	  (list
	   (format "TERM=%s" term-term-name)
	   (format "TERMINFO=%s"
                   (term-generate-db-directory))
	   (format term-termcap-format "TERMCAP="
		   term-term-name term-height term-width)

	   (format "INSIDE_EMACS=%s,term:%s"
                   emacs-version term-protocol-version))
          (when term-set-terminal-size
            (list
             (format "LINES=%d" term-height)
	     (format "COLUMNS=%d" term-width)))
	  process-environment))
	(process-connection-type t)
	;; We should suppress conversion of end-of-line format.
	(inhibit-eol-conversion t)
	;; The process's output contains not just chars but also binary
	;; escape codes, so we need to see the raw output.  We will have to
	;; do the decoding by hand on the parts that are made of chars.
	(coding-system-for-read 'binary))
    (when (term--bash-needs-EMACSp)
      (push (format "EMACS=%s (term:%s)" emacs-version term-protocol-version)
            process-environment))
    (apply #'start-process name buffer
           ;; On Android, /bin doesn't exist, and the default shell is
           ;; found as /system/bin/sh.
	   (if (eq system-type 'android)
               "/system/bin/sh"
             "/bin/sh")
           "-c"
	   (format "stty -nl echo rows %d columns %d sane 2>%s;\
if [ $1 = .. ]; then shift; fi; exec \"$@\""
		   term-height term-width null-device)
	   ".."
	   command switches)))