Function: eshell-get-variable

eshell-get-variable is a byte-compiled function defined in esh-var.el.gz.

Signature

(eshell-get-variable NAME &optional INDICES QUOTED)

Documentation

Get the value for the variable NAME.

INDICES is a list of index-lists (see eshell-parse-indices). If QUOTED is non-nil, this was invoked inside double-quotes.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-var.el.gz
(defun eshell-get-variable (name &optional indices quoted)
  "Get the value for the variable NAME.
INDICES is a list of index-lists (see `eshell-parse-indices').
If QUOTED is non-nil, this was invoked inside double-quotes."
  (if-let* ((alias (assoc name eshell-variable-aliases-list)))
      (let ((target (nth 1 alias)))
        (when (and (not (functionp target))
                   (consp target))
          (setq target (car target)))
        (cond
         ((functionp target)
          (if (nth 3 alias)
              (eshell-apply-indices (funcall target) indices quoted)
            (let ((max-arity (cdr (func-arity target))))
              (if (or (eq max-arity 'many) (>= max-arity 2))
                  (funcall target indices quoted)
                (display-warning
                 '(eshell variable-alias)
                 (concat "Function for `eshell-variable-aliases-list' "
                         "entry should accept two arguments: INDICES "
                         "and QUOTED.'"))
                (funcall target indices)))))
         ((symbolp target)
          (eshell-apply-indices (symbol-value target) indices quoted))
         (t
          (eshell-get-variable target indices quoted))))
    (unless (stringp name)
      (error "Unknown variable `%s'" (eshell-stringify name)))
    (eshell-apply-indices
     (let ((sym (intern-soft name)))
       (if (and sym (boundp sym)
		(or eshell-prefer-lisp-variables
		    (memq sym eshell--local-vars) ; bug#15372
		    (not (getenv name))))
	   (symbol-value sym)
	 (getenv name)))
     indices quoted)))