Skip to content

Commit 2c3d1b6

Browse files
jimporterEli-Zaretskii
authored andcommitted
Improve/correct documentation about Eshell variable expansion
* lisp/eshell/esh-var.el: Correct documentation comment. (eshell-parse-variable-ref): Correct docstring. * doc/misc/eshell.texi (Dollars Expansion): Add documentation for $"var"/$'var' and $<command> syntaxes.
1 parent 9e257ae commit 2c3d1b6

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

doc/misc/eshell.texi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,12 @@ of familiarity.
583583
Expands to the value bound to @code{var}. This is the main way to use
584584
variables in command invocations.
585585

586+
@item $"var"
587+
@item $'var'
588+
Expands to the value bound to @code{var}. This is useful to
589+
disambiguate the variable name when concatenating it with another
590+
value, such as @samp{$"var"-suffix}.
591+
586592
@item $#var
587593
Expands to the length of the value bound to @code{var}. Raises an error
588594
if the value is not a sequence
@@ -597,6 +603,11 @@ it can be used in a string, such as @samp{/some/path/$(lisp).txt}.
597603
Returns the output of @command{command}, which can be any valid Eshell
598604
command invocation, and may even contain expansions.
599605

606+
@item $<command>
607+
As with @samp{$@{command@}}, evaluates the Eshell command invocation
608+
@command{command}, but writes the output to a temporary file and
609+
returns the file name.
610+
600611
@item $var[i]
601612
Expands to the @code{i}th element of the value bound to @code{var}. If
602613
the value is a string, it will be split at whitespace to make it a list.

lisp/eshell/esh-var.el

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
;;
3535
;; "-" is a valid part of a variable name.
3636
;;
37-
;; $<MYVAR>-TOO
37+
;; $\"MYVAR\"-TOO
38+
;; $'MYVAR'-TOO
3839
;;
3940
;; Only "MYVAR" is part of the variable name in this case.
4041
;;
@@ -55,6 +56,11 @@
5556
;; Returns the value of an eshell subcommand. See the note above
5657
;; regarding Lisp evaluations.
5758
;;
59+
;; $<command>
60+
;;
61+
;; Evaluates an eshell subcommand, redirecting the output to a
62+
;; temporary file, and returning the file name.
63+
;;
5864
;; $ANYVAR[10]
5965
;;
6066
;; Return the 10th element of ANYVAR. If ANYVAR's value is a string,
@@ -426,9 +432,12 @@ variable.
426432
Possible options are:
427433
428434
NAME an environment or Lisp variable value
429-
<LONG-NAME> disambiguates the length of the name
435+
\"LONG-NAME\" disambiguates the length of the name
436+
'LONG-NAME' as above
430437
{COMMAND} result of command is variable's value
431-
(LISP-FORM) result of Lisp form is variable's value"
438+
(LISP-FORM) result of Lisp form is variable's value
439+
<COMMAND> write the output of command to a temporary file;
440+
result is the file name"
432441
(cond
433442
((eq (char-after) ?{)
434443
(let ((end (eshell-find-delimiter ?\{ ?\})))

0 commit comments

Comments
 (0)