2.2 Arguments

Ordinarily, Eshell parses arguments in command form as either strings or numbers, depending on what the parser thinks they look like. To specify an argument of some other data type, you can use a Lisp form (see Invocation):

~ $ echo (list 1 2 3)
(1 2 3)

Additionally, many built-in Eshell commands (see Built-in commands) will flatten the arguments they receive, so passing a list as an argument will “spread” the elements into multiple arguments:

~ $ printnl (list 1 2) 3
1
2
3

2.2.1 Quoting and escaping

As with other shells, you can escape special characters and spaces by prefixing the character with a backslash (‘\’), or by surrounding the string with apostrophes (‘''’) or double quotes (‘""’). This is needed especially for file names with special characters like pipe (‘|’) or square brackets (‘[’ or ‘]’), which could be part of remote file names.

When you escape a character with ‘\’ outside of any quotes, the result is the literal character immediately following it. For example, \$10 means the literal string $10.

Inside of double quotes, most characters have no special meaning. However, ‘\’, ‘"’, and ‘$’ are still special; to escape them, use backslash as above. Thus, if the value of the variable answer is 42, then "The answer is: \"$answer\"" returns the string The answer is: "42". However, when escaping characters with no special meaning, the result is the full \c sequence. For example, "foo\bar" means the literal string foo\bar.

Additionally, when escaping a newline, the whole escape sequence is removed by the parser. This lets you continue commands across multiple lines:

~ $ echo "foo\
bar"
foobar

Inside apostrophes, escaping works differently. All characters between the apostrophes have their literal meaning except ‘'’, which ends the quoted string. To insert a literal apostrophe, you can use ‘''’, so 'It''s me' means the literal string It's me.

When using expansions (see Expansion) in an Eshell command, the result may potentially be of any data type. To ensure that the result is always a string, the expansion can be surrounded by double quotes.

2.2.2 Special argument types

In addition to strings and numbers, Eshell supports a number of special argument types. These let you refer to various other Emacs Lisp data types, such as lists or buffers.

#'lisp-form

This refers to the quoted Emacs Lisp form lisp-form. Though this looks similar to the “sharp quote” syntax for functions (see Special Read Syntax in The Emacs Lisp Reference Manual), it instead corresponds to quote and can be used for any quoted form.5

`lisp-form

This refers to the backquoted Emacs Lisp form lisp-form (see Backquote in The Emacs Lisp Reference Manual). As in Emacs Lisp, you can use ‘,’ and ‘,@’ to refer to non-constant values.

#<buffer name>
#<name>

Return the buffer named name. This is equivalent to ‘$(get-buffer-create "name")’ (see Creating Buffers in The Emacs Lisp Reference Manual).

#<process name>

Return the process named name. This is equivalent to ‘$(get-process "name")’ (see Process Information in The Emacs Lisp Reference Manual).


Footnotes

(5)

Eshell would interpret a bare apostrophe (') as the start of a single-quoted string.