(defvar eshell-last-dir-ring nil
"The last directory that Eshell was in.")
+(defconst eshell-inside-emacs (format "%s,eshell" emacs-version)
+ "Value for the `INSIDE_EMACS' environment variable.")
+
;;; Functions:
(defun eshell-dirs-initialize () ;Called from `eshell-mode' via intern-soft!
(unless (ring-empty-p eshell-last-dir-ring)
(expand-file-name
(ring-ref eshell-last-dir-ring 0))))
+ t)
+ ("INSIDE_EMACS" eshell-inside-emacs
t))))
(when eshell-cd-on-directory
(eshell-apply-indices eshell-command-arguments
indices)))))
"This list provides aliasing for variable references.
-It is very similar in concept to what `eshell-user-aliases-list' does
-for commands. Each member of this defines the name of a command,
-and the Lisp value to return for that variable if it is accessed
-via the syntax `$NAME'.
+Each member defines the name of a variable, and a Lisp value used to
+compute the string value that will be returned when the variable is
+accessed via the syntax `$NAME'.
If the value is a function, that function will be called with two
arguments: the list of the indices that was used in the reference, and
For example, a reference of `$NAME[10][20]' would result in the
function for alias `NAME' being called (assuming it were aliased to a
function), and the arguments passed to this function would be the list
-'(10 20)', and nil."
+'(10 20)', and nil.
+
+If the value is a string, the value for the variable with that name in
+the current environment will be returned. If no variable with that
+name exists in the environment, but if a symbol with that same name
+exists and has a value bound to it, then that value will be used. You
+can prioritize symbol values over environment values by setting
+`eshell-prefer-lisp-variables' to t.
+
+If the value is a symbol, the value bound to that symbol will be used.
+
+If the value has any other type, `error' will be signaled.
+
+Additionally, each member may specify if it should be copied to the
+environment of created subprocesses."
:type '(repeat (list string sexp
(choice (const :tag "Copy to environment" t)
(const :tag "Use only in Eshell" nil)))))
(eshell-command-result-p "+ 1 2; + $_ 4"
"3\n6\n")))
+(ert-deftest eshell-test/inside-emacs-var ()
+ "Test presence of \"INSIDE_EMACS\" in subprocesses"
+ (with-temp-eshell
+ (eshell-command-result-p "env"
+ (format "INSIDE_EMACS=%s,eshell"
+ emacs-version))))
+
(ert-deftest eshell-test/escape-nonspecial ()
"Test that \"\\c\" and \"c\" are equivalent when \"c\" is not a
special character."