neulab/tldr huggingface dataset:
Errors can for example be ^ERR-BADMSG when requesting an invalid message, ^ERR-NOMSG if no applicable message can be found, ^ERR-CANCELED for missing informational data (mostly thread-related).  ^ERR-INVAL for invalid syntax as well as ^ERR-IO for input/output errors can happen.  The following special message names exist:
.         The current message, the so-called “dot”.
;         The message that was previously the current message; needs to be quoted.
,         The parent message of the current message, that is the message with the Message-ID given in the ‘In-Reply-To:’ field or the last entry of the ‘References:’ field of the current message.
-         The previous undeleted message, or the previous deleted message for the undelete command; In sorted or ‘thread’ed mode, the previous such message in the according order.
+         The next undeleted message, or the next deleted message for the undelete command; In sorted or ‘thread’ed mode, the next such message in the according order.
^         The first undeleted message, or the first deleted message for the undelete command; In sorted or ‘thread’ed mode, the first such message in the according order.
$         The last message; In sorted or ‘thread’ed mode, the last such message in the according order.  Needs to be quoted.
&x        In ‘thread’ed sort mode, selects the message addressed with x, where x is any other message specification, and all messages from the thread that begins at it.  Otherwise it is identical to x. If x is omitted, the thread beginning with the current message is selected.
*         All messages.
`         All messages that were included in the Message list arguments of the previous command; needs to be quoted.  (A convenient way to read all new messages is to select them via ‘from :n’, as below, and then to read them in order with the default command — next — simply by successively typing ‘`’; for this to work showlast must be set.)
x-y       An inclusive range of message numbers.  Selectors that may also be used as endpoints include any of .;-+^$.
address   A case-insensitive “any substring matches” search against the ‘From:’ header, which will match addresses (too) even if showname is set (and POSIX says “any address as shown in a header summary shall be matchable in this form”); However, if the allnet variable is set, only the local part of the address is evaluated for the comparison, not ignoring case, and the setting of showname is completely ignored.  For finer control and match boundaries use the ‘@’ search expression.
/string   All messages that contain string in the subject field (case ignored according to locale).  See also the searchheaders variable.  If string is empty, the string from the previous specification of that type is used again.
[@name-list]@expr All messages that contain the given case-insensitive search expression;  If the [Option]al regular expression support is available expr will be interpreted as (an extended) one if any of the magic regular expression characters is seen.  If the optional @name-list part is missing the search is restricted to the subject field body, but otherwise name-list specifies a comma- separated list of header fields to search, for example
'@to,from,cc@Someone i ought to know'
In order to search for a string that includes a ‘@’ (commercial at) character the name-list is effectively non-optional, but may be given as the empty string.  Also, specifying an empty search expression will effectively test for existence of the given header fields.  Some special header fields may be abbreviated: ‘f’, ‘t’, ‘c’, ‘b’ and ‘s’ will match ‘From’, ‘To’, ‘Cc’, ‘Bcc’ and ‘Subject’, respectively and case-insensitively. [Option]ally, and just like expr, name-list will be interpreted as (an extended) regular expression if any of the magic regular expression characters is seen.
The special names ‘header’ or ‘<’ can be used to search in (all of) the header(s) of the message, and the special names ‘body’ or ‘>’ and ‘text’ or ‘=’ will perform full text searches – whereas the former searches only the body, the latter also searches the message header ([v15 behaviour may differ] this mode yet brute force searches over the entire decoded content of messages, including administrativa strings).
This specification performs full text comparison, but even with regular expression support it is almost impossible to write a search expression that safely matches only a specific address domain.  To request that the body content of the header is treated as a list of addresses, and to strip those down to the plain email address which the search expression is to be matched against, prefix the effective name-list with a tilde ‘~’:
'@~f,c@@a\.safe\.domain\.match$'
:c        All messages of state or with matching condition ‘c’, where ‘c’ is one or multiple of the following colon modifiers:
a         answered messages (cf. the variable markanswered). d         ‘deleted’ messages (for the undelete and from commands only). f         flagged messages. L         Messages with receivers that match mlsubscribed addresses. l         Messages with receivers that match mlisted addresses. n         ‘new’ messages. o         Old messages (any not in state ‘read’ or ‘new’). r         ‘read’ messages. S         [Option] Messages with unsure spam classification (see Handling spam). s         [Option] Messages classified as spam. t         Messages marked as draft. u         ‘unread’ messages.
[Option] IMAP-style SEARCH expressions may also be used.  These consist of keywords and criterions, and because Message list arguments are split into tokens according to Shell-style argument quoting it is necessary to quote the entire IMAP search expression in order to ensure that it remains a single token.  This addressing mode is available with all types of mailbox folders; Mail will perform the search locally as necessary.  Strings must be enclosed by double quotation marks ‘"’ in their entirety if they contain whitespace or parentheses; within the quotes, only reverse solidus ‘\’ is recognized as an escape character.  All string searches are case- insensitive.  When the description indicates that the “envelope” representation of an address field is used, this means that the search string is checked against both a list constructed as
'("name" "source" "local-part" "domain-part")'
for each address, and the addresses without real names from the respective header field.  These search expressions can be nested using parentheses, see below for examples.
(criterion) All messages that satisfy the given criterion. (criterion1 criterion2 ... criterionN) All messages that satisfy all of the given criteria. (or criterion1 criterion2) All messages that satisfy either criterion1 or criterion2, or both.  To connect more than two criteria using ‘or’ specifications have to be nested using additional parentheses, as with ‘(or a (or b c))’, since ‘(or a b c)’ really means ‘((a or b) and c)’.  For a simple ‘or’ operation of independent criteria on the lowest nesting level, it is possible to achieve similar effects by using three separate criteria, as with ‘(a) (b) (c)’. (not criterion) All messages that do not satisfy criterion. (bcc "string") All messages that contain string in the envelope representation of the ‘Bcc:’ field. (cc "string") All messages that contain string in the envelope representation of the ‘Cc:’ field. (from "string") All messages that contain string in the envelope representation of the ‘From:’ field. (subject "string") All messages that contain string in the ‘Subject:’ field. (to "string") All messages that contain string in the envelope representation of the ‘To:’ field. (header name "string") All messages that contain string in the specified ‘Name:’ field. (body "string") All messages that contain string in their body. (text "string") All messages that contain string in their header or body. (larger size) All messages that are larger than size (in bytes). (smaller size) All messages that are smaller than size (in bytes). (before date) All messages that were received before date, which must be in the form ‘d[d]-mon-yyyy’, where ‘d’ denotes the day of the month as one or two digits, ‘mon’ is the name of the month – one of ‘Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec’, and ‘yyyy’ is the year as four digits, for example ‘28-Dec-2012’. (on date) All messages that were received on the specified date. (since date) All messages that were received since the specified date. (sentbefore date) All messages that were sent on the specified date. (senton date) All messages that were sent on the specified date. (sentsince date) All messages that were sent since the specified date. ()        The same criterion as for the previous search.  This specification cannot be used as part of another criterion.  If the previous command line contained more than one independent criterion then the last of those criteria is used.
On terminal control and line editor [Option] Terminal control through one of the standard UNIX libraries, Termcap Access Library (libtermcap, -ltermcap) or Terminal Information Library (libterminfo, -lterminfo), may be available.  For the TERMinal defined in the environment interactive usage aspects, for example Coloured display, and insight of cursor and function keys for the Mailx-Line-Editor (MLE), will be enhanced or enabled.  Library interaction can be disabled on a per-invocation basis via termcap-disable, whereas the internal variable termcap is always used as a preferred source of terminal capabilities. (For a usage example see the FAQ entry Not "defunctional", but the editor key does not work.)
[Option] The built-in Mailx-Line-Editor (MLE) should work in all environments which comply to the ISO C standard ISO/IEC 9899/AMD1:1995 (“ISO C90, Amendment 1”), and will support wide glyphs if possible (the necessary functionality had been removed from ISO C, but was included in X/Open Portability Guide Issue 4 (“XPG4”)).  Usage of a line editor in interactive mode can be prevented by setting line-editor-disable. Especially if the [Option]al terminal control support is missing setting entries in termcap will help shall the MLE misbehave, see there for more. The MLE can support a little bit of colour.
[Option] If the history feature is available then input from line editor prompts will be saved in a history list that can be searched in and be expanded from.  Such saving can be prevented by prefixing input with any amount of whitespace.  Aspects of history, like allowed content and maximum size, as well as whether history shall be saved persistently, can be configured with the internal variables history-file, history-gabby, history-gabby-persist and history-size.  There also exists the macro hook on-history-addition which can be used to apply finer control on what enters history.
The MLE supports a set of editing and control commands.  By default (as) many (as possible) of these will be assigned to a set of single-letter control codes, which should work on any terminal (and can be generated by holding the “control” key while pressing the key of desire, for example ‘control-D’).  If the [Option]al bind command is available then the MLE commands can also be accessed freely by assigning the command name, which is shown in parenthesis in the list below, to any desired key-sequence, and the MLE will instead and also use bind to establish its built-in key bindings (more of them if the [Option]al terminal control is available), an action which can then be suppressed completely by setting line-editor-no-defaults.  Shell-style argument quoting notation is used in the following:
Coloured display [Option] Colours and font attributes through ANSI a.k.a. ISO 6429 SGR (select graphic rendition) escape sequences are optionally supported. Usage of colours and font attributes solely depends upon the capability of the detected terminal type (TERM), and as fine-tuned through termcap. Colours and font attributes can be managed with the multiplexer command colour, and uncolour removes the given mappings.  Setting colour-disable suppresses usage of colour and font attribute sequences, while leaving established mappings unchanged.
Whether actually applicable colour and font attribute sequences should also be generated when output is going to be paged through the external PAGER (also see crt) depends upon the setting of colour-pager, because pagers usually need to be configured in order to support ISO escape sequences. Knowledge of some widely used pagers is however built-in, and in a clean environment it is often enough to simply set colour-pager; please refer to that variable for more on this topic.
It might make sense to conditionalize colour setup on interactive mode via if (‘terminal’ indeed means “interactive”):
if terminal && "$features" =% ,+colour, colour iso view-msginfo ft=bold,fg=green colour iso view-header ft=bold,fg=red (from|subject) # regex colour iso view-header fg=red
uncolour iso view-header from,subject colour iso view-header ft=bold,fg=magenta,bg=cyan colour 256 view-header ft=bold,fg=208,bg=230 "subject,from" colour mono view-header ft=bold colour mono view-header ft=bold,ft=reverse subject,from endif
Handling spam [Option] Mail can make use of several spam interfaces for the purpose of identification of, and, in general, dealing with spam messages.  A precondition of most commands in order to function is that the spam-interface variable is set to one of the supported interfaces. Specifying messages that have been identified as spam is possible via their (volatile) ‘is-spam’ state by using the ‘:s’ and ‘:S’ specifications, and their attrlist entries will be used when displaying the headline in the summary of headers.
•   spamrate rates the given messages and sets their ‘is-spam’ flag accordingly.  If the spam interface offers spam scores these can be shown in headline by using the format ‘%$’.
•   spamham, spamspam and spamforget will interact with the Bayesian filter of the chosen interface and learn the given messages as “ham” or “spam”, respectively; the last command can be used to cause “unlearning” of messages; it adheres to their current ‘is-spam’ state and thus reverts previous teachings.
•   spamclear and spamset will simply set and clear, respectively, the mentioned volatile ‘is-spam’ message flag, without any interface interaction.
The spamassassin(1) based spam-interface ‘spamc’ requires a running instance of the spamd(1) server in order to function, started with the option --allow-tell shall Bayesian filter learning be possible.
$ spamd -i localhost:2142 -i /tmp/.spamsock -d [-L] [-l] $ spamd --listen=localhost:2142 --listen=/tmp/.spamsock \ --daemonize [--local] [--allow-tell]
Thereafter Mail can make use of these interfaces:
$ mail -Sspam-interface=spamc -Sspam-maxsize=500000 \ -Sspamc-command=/usr/local/bin/spamc \ -Sspamc-arguments="-U /tmp/.spamsock" -Sspamc-user= or $ mail -Sspam-interface=spamc -Sspam-maxsize=500000 \ -Sspamc-command=/usr/local/bin/spamc \ -Sspamc-arguments="-d localhost -p 2142" -Sspamc-user=
Using the generic filter approach allows usage of programs like bogofilter(1).  Here is an example, requiring it to be accessible via PATH:
$ mail -Sspam-interface=filter -Sspam-maxsize=500000 \ -Sspamfilter-ham="bogofilter -n" \ -Sspamfilter-noham="bogofilter -N" \ -Sspamfilter-nospam="bogofilter -S" \ -Sspamfilter-rate="bogofilter -TTu 2>/dev/null" \ -Sspamfilter-spam="bogofilter -s" \ -Sspamfilter-rate-scanscore="1;^(.+)$"
Because messages must exist on local storage in order to be scored (or used for Bayesian filter training), it is possibly a good idea to perform the local spam check last.  Spam can be checked automatically when opening specific folders by setting a specialized form of the internal variable folder-hook.
define spamdelhook { # Server side DCC spamset (header x-dcc-brand-metrics "bulk") # Server-side spamassassin(1) spamset (header x-spam-flag "YES") del :s # TODO we HAVE to be able to do `spamrate :u ! :sS' move :S +maybe-spam spamrate :u del :s move :S +maybe-spam } set folder-hook-SOMEFOLDER=spamdelhook
See also the documentation for the variables spam-interface, spam-maxsize, spamc-command, spamc-arguments, spamc-user, spamfilter-ham, spamfilter-noham, spamfilter-nospam, spamfilter-rate and spamfilter-rate-scanscore.
Mail reads input in lines.  An unquoted reverse solidus ‘\’ at the end of a command line “escapes” the newline character: it is discarded and the next line of input is used as a follow-up line, with all leading whitespace removed; once an entire line is completed, the whitespace characters space, tabulator, newline as well as those defined by the variable ifs are removed from the beginning and end.  Placing any whitespace characters at the beginning of a line will prevent a possible addition of the command line to the [Option]al history.
The beginning of such input lines is then scanned for the name of a known command: command names may be abbreviated, in which case the first command that matches the given prefix will be used.  Command modifiers may prefix a command in order to modify its behaviour.  A name may also be a commandalias, which will become expanded until no more expansion is possible.  Once the command that shall be executed is known, the remains of the input line will be interpreted according to command-specific rules, documented in the following.
This behaviour is different to the sh(1)ell, which is a programming language with syntactic elements of clearly defined semantics, and therefore capable to sequentially expand and evaluate individual elements of a line.  ‘? set one=value two=$one’ for example will never possibly assign value to one, because the variable assignment is performed no sooner but by the command (set), long after the expansion happened.
A list of all commands in lookup order is dumped by the command list. [Option]ally the command help (or ?), when given an argument, will show a documentation string for the command matching the expanded argument, as in ‘?t’, which should be a shorthand of ‘?type’; with these documentation strings both commands support a more verbose listing mode which includes the argument type of the command and other information which applies; a handy suggestion might thus be:
? define __xv { # Before v15: need to enable sh(1)ell-style on _entire_ line! localopts yes;wysh set verbose;ignerr eval "${@}";return ${?} } ? commandalias xv '\call __xv' ? xv help set
Command modifiers Commands may be prefixed by none to multiple command modifiers.  Some command modifiers can be used with a restricted set of commands only, the verbose version of list will ([Option]ally) show which modifiers apply.
•   The modifier reverse solidus \, to be placed first, prevents commandalias expansions on the remains of the line, for example ‘\echo’ will always evaluate the command echo, even if an (command)alias of the same name exists.  commandalias content may itself contain further command modifiers, including an initial reverse solidus to prevent further expansions.
•   The modifier ignerr indicates that any error generated by the following command should be ignored by the state machine and not cause a program exit with enabled errexit or for the standardized exit cases in posix mode.  ?, one of the INTERNAL VARIABLES, will be set to the real exit status of the command regardless.
•   local will alter the called command to apply changes only temporarily, local to block-scope, and can thus only be used inside of a defined macro or an account definition.  Specifying it implies the modifier wysh.  Local variables will not be inherited by macros deeper in the call chain, and all local settings will be garbage collected once the local scope is left.  To record and unroll changes in the global scope use the command localopts.
•   scope does yet not implement any functionality.
•   u does yet not implement any functionality.
•   Some commands support the vput modifier: if used, they expect the name of a variable, which can itself be a variable, i.e., shell expansion is applied, as their first argument, and will place their computation result in it instead of the default location (it is usually written to standard output).
The given name will be tested for being a valid sh(1) variable name, and may therefore only consist of upper- and lowercase characters, digits, and the underscore; the hyphen-minus may be used as a non- portable extension; digits may not be used as first, hyphen-minus may not be used as last characters.  In addition the name may either not be one of the known INTERNAL VARIABLES, or must otherwise refer to a writable (non-boolean) value variable.  The actual put operation may fail nonetheless, for example if the variable expects a number argument only a number will be accepted.  Any error during these operations causes the command as such to fail, and the error number ! will be set to ^ERR-NOTSUP, the exit status ? should be set to ‘-1’, but some commands deviate from the latter, which is documented.
•   Last, but not least, the modifier wysh can be used for some old and established commands to choose the new Shell-style argument quoting rules over the traditional Old-style argument quoting.  This modifier is implied if v15-compat is set to a non-empty value.
Old-style argument quoting [v15 behaviour may differ] This section documents the traditional and POSIX standardized style of quoting non-message list arguments to commands which expect this type of arguments: whereas still used by the majority of such commands, the new Shell-style argument quoting may be available even for those via wysh, one of the Command modifiers.  Nonetheless care must be taken, because only new commands have been designed with all the capabilities of the new quoting rules in mind, which can, for example generate control characters.
•   An argument can be enclosed between paired double-quotes ‘"argument"’ or single-quotes ‘'argument'’; any whitespace, shell word expansion, or reverse solidus characters (except as described next) within the quotes are treated literally as part of the argument.  A double-quote will be treated literally within single-quotes and vice versa.  Inside such a quoted string the actually used quote character can be used nonetheless by escaping it with a reverse solidus ‘\’, as in ‘"y\"ou"’.
•   An argument that is not enclosed in quotes, as above, can usually still contain space characters if those spaces are reverse solidus escaped, as in ‘you\ are’.
•   A reverse solidus outside of the enclosing quotes is discarded and the following character is treated literally as part of the argument.
Shell-style argument quoting sh(1)ell-style, and therefore POSIX standardized, argument parsing and quoting rules are used by most commands.  [v15 behaviour may differ] Most new commands only support these new rules and are flagged [Only new quoting rules], some elder ones can use them with the command modifier wysh; in the future only this type of argument quoting will remain.
A command line is parsed from left to right and an input token is completed whenever an unquoted, otherwise ignored, metacharacter is seen. Metacharacters are vertical bar |, ampersand &, semicolon ;, as well as all characters from the variable ifs, and / or space, tabulator, newline.  The additional metacharacters left and right parenthesis (, ) and less-than and greater-than signs <, > that the sh(1) supports are not used, and are treated as ordinary characters: for one these characters are a vivid part of email addresses, and it seems highly unlikely that their function will become meaningful to Mail.
Compatibility note: [v15 behaviour may differ] Please note that even many new-style commands do not yet honour ifs to parse their arguments: whereas the sh(1)ell is a language with syntactic elements of clearly defined semantics, Mail parses entire input lines and decides on a per-command base what to do with the rest of the line. This also means that whenever an unknown command is seen all that Mail can do is cancellation of the processing of the remains of the line.
It also often depends on an actual subcommand of a multiplexer command how the rest of the line should be treated, and until v15 we are not capable to perform this deep inspection of arguments. Nonetheless, at least the following commands which work with positional parameters fully support ifs for an almost shell- compatible field splitting: call, call_if, read, vpospar, xcall.
Any unquoted number sign ‘#’ at the beginning of a new token starts a comment that extends to the end of the line, and therefore ends argument processing.  An unquoted dollar sign ‘$’ will cause variable expansion of the given name, which must be a valid sh(1)ell-style variable name (see vput): INTERNAL VARIABLES as well as ENVIRONMENT (shell) variables can be accessed through this mechanism, brace enclosing the name is supported (i.e., to subdivide a token).
Whereas the metacharacters space, tabulator, newline only complete an input token, vertical bar |, ampersand & and semicolon ; also act as control operators and perform control functions.  For now supported is semicolon ;, which terminates a single command, therefore sequencing the command line and making the remainder of the line a subject to reevaluation.  With sequencing, multiple command argument types and quoting rules may therefore apply to a single line, which can become problematic before v15: e.g., the first of the following will cause surprising results.
? echo one; set verbose; echo verbose=$verbose. ? echo one; wysh set verbose; echo verbose=$verbose.
Quoting is a mechanism that will remove the special meaning of metacharacters and reserved words, and will prevent expansion.  There are four quoting mechanisms: the escape character, single-quotes, double-quotes and dollar-single-quotes:
•   The literal value of any character can be preserved by preceding it with the escape character reverse solidus ‘\’.
•   Arguments which are enclosed in ‘'single-quotes'’ retain their literal value.  A single-quote cannot occur within single-quotes.
•   The literal value of all characters enclosed in ‘"double-quotes"’ is retained, with the exception of dollar sign ‘$’, which will cause variable expansion, as above, backquote (grave accent) ‘`’, (which not yet means anything special), reverse solidus ‘\’, which will escape any of the characters dollar sign ‘$’ (to prevent variable expansion), backquote (grave accent) ‘`’, double-quote ‘"’ (to prevent ending the quote) and reverse solidus ‘\’ (to prevent escaping, i.e., to embed a reverse solidus character as-is), but has no special meaning otherwise.
•   Arguments enclosed in ‘$'dollar-single-quotes'’ extend normal single quotes in that reverse solidus escape sequences are expanded as follows:
‘\a’    bell control character (ASCII and ISO-10646 BEL). ‘\b’    backspace control character (ASCII and ISO-10646 BS). ‘\E’    escape control character (ASCII and ISO-10646 ESC). ‘\e’    the same. ‘\f’    form feed control character (ASCII and ISO-10646 FF). ‘\n’    line feed control character (ASCII and ISO-10646 LF). ‘\r’    carriage return control character (ASCII and ISO-10646 CR). ‘\t’    horizontal tabulator control character (ASCII and ISO-10646 HT). ‘\v’    vertical tabulator control character (ASCII and ISO-10646 VT). ‘\\’    emits a reverse solidus character. ‘\'’    single quote. ‘\"’    double quote (escaping is optional). ‘\NNN’  eight-bit byte with the octal value ‘NNN’ (one to three octal digits), optionally prefixed by an additional ‘0’. A 0 byte will suppress further output for the quoted argument. ‘\xHH’  eight-bit byte with the hexadecimal value ‘HH’ (one or two hexadecimal characters, no prefix, see vexpr).  A 0 byte will suppress further output for the quoted argument. ‘\UHHHHHHHH’ the Unicode / ISO-10646 character with the hexadecimal codepoint value ‘HHHHHHHH’ (one to eight hexadecimal characters) — note that Unicode defines the maximum codepoint ever to be supported as ‘0x10FFFF’ (in planes of ‘0xFFFF’ characters each).  This escape is only supported in locales that support Unicode (see Character sets), in other cases the sequence will remain unexpanded unless the given code point is ASCII compatible or (if the [Option]al character set conversion is available) can be represented in the current locale.  The character NUL will suppress further output for the quoted argument. ‘\uHHHH’ Identical to ‘\UHHHHHHHH’ except it takes only one to four hexadecimal characters. ‘\cX’   Emits the non-printable (ASCII and compatible) C0 control codes 0 (NUL) to 31 (US), and 127 (DEL).  Printable representations of ASCII control codes can be created by mapping them to a different, visible part of the ASCII character set.  Adding the number 64 achieves this for the codes 0 to 31, here 7 (BEL): ‘7 + 64 = 71 = G’.  The real operation is a bitwise logical XOR with 64 (bit 7 set, see vexpr), thus also covering code 127 (DEL), which is mapped to 63 (question mark): ‘? vexpr ^ 127 64’.
Whereas historically circumflex notation has often been used for visualization purposes of control codes, as in ‘^G’, the reverse solidus notation has been standardized: ‘\cG’.  Some control codes also have standardized (ISO-10646, ISO C) aliases, as shown above (‘\a’, ‘\n’, ‘\t’ etc) : whenever such an alias exists it will be used for display purposes.  The control code NUL (‘\c@’, a non-standard extension) will suppress further output for the remains of the token (which may extend beyond the current quote), or, depending on the context, the remains of all arguments for the current command. ‘\$NAME’ Non-standard extension: expand the given variable name, as above.  Brace enclosing the name is supported. ‘\`{command}’ Not yet supported, just to raise awareness: Non-standard extension.
Caveats:
? echo 'Quotes '${HOME}' and 'tokens" differ!"# no comment ? echo Quotes ${HOME} and tokens differ! # comment ? echo Don"'"t you worry$'\x21' The sun shines on us. $'\u263A'
Message list arguments Many commands operate on message list specifications, as documented in Specifying messages.  The argument input is first split into individual tokens via Shell-style argument quoting, which are then interpreted as the mentioned specifications.  If no explicit message list has been specified, many commands will search for and use the next message forward that satisfies the commands' requirements, and if there are no messages forward of the current message, the search proceeds backwards; if there are no good messages at all to be found, an error message is shown and the command is aborted.  The verbose output of the command list will indicate whether a command searches for a default message, or not.
Raw data arguments for codec commands A special set of commands, which all have the string “codec” in their name, like addrcodec, shcodec, urlcodec, take raw string data as input, which means that the content of the command input line is passed completely unexpanded and otherwise unchanged: like this the effect of the actual codec is visible without any noise of possible shell quoting rules etc., i.e., the user can input one-to-one the desired or questionable data.  To gain a level of expansion, the entire command line can be evaluated first, for example
? vput shcodec res encode /usr/Schönes Wetter/heute.txt ? echo $res $'/usr/Sch\u00F6nes Wetter/heute.txt' ? shcodec d $res $'/usr/Sch\u00F6nes Wetter/heute.txt' ? eval shcodec d $res /usr/Schönes Wetter/heute.txt
Filename transformations Filenames, where expected, and unless documented otherwise, are subsequently subject to the following filename transformations, in sequence:
•   If the given name is a registered shortcut, it will be replaced with the expanded shortcut.  This step is mostly taken for folders only.
•   The filename is matched against the following patterns or strings.  But for plus +file folder expansion this step is mostly taken for folders only.
#      (Number sign) is expanded to the previous file. %      (Percent sign) is replaced by the invoking user's primary system mailbox, which either is the (itself expandable) inbox if that is set, the standardized absolute pathname indicated by MAIL if that is set, or a built-in compile- time default otherwise.  When opening a folder the used name is actively checked for being a primary mailbox, first against inbox, then against MAIL. %user  Expands to the primary system mailbox of user (and never the value of inbox, regardless of its actual setting). &      (Ampersand) is replaced with the invoking user's secondary mailbox, the MBOX. +file  Refers to a file in the folder directory (if that variable is set). %:filespec Expands to the same value as filespec, but has special meaning when used with, for example, the command folder: the file will be treated as a primary system mailbox by, among others, the mbox and save commands, meaning that messages that have been read in the current session will be moved to the MBOX mailbox instead of simply being flagged as read.
•   Meta expansions may be applied to the resulting filename, as allowed by the operation and applicable to the resulting access protocol (also see On URL syntax and credential lookup).  For the file-protocol, a leading tilde ‘~’ character will be replaced by the expansion of HOME, except when followed by a valid user name, in which case the home directory of the given user is used instead.
A shell expansion as if specified in double-quotes (see Shell-style argument quoting) may be applied, so that any occurrence of ‘$VARIABLE’ (or ‘${VARIABLE}’) will be replaced by the expansion of the variable, if possible; INTERNAL VARIABLES as well as ENVIRONMENT (shell) variables can be accessed through this mechanism.
Shell pathname wildcard pattern expansions (glob(7)) may be applied as documented.  If the fully expanded filename results in multiple pathnames and the command is expecting only one file, an error results.
In interactive context, in order to allow simple value acceptance (via “ENTER”), arguments will usually be displayed in a properly quoted form, so a file ‘diet\ is \curd.txt’ may be displayed as ‘'diet\ is \curd.txt'’.
Commands The following commands are available:
!         Executes the SHELL command which follows, replacing unescaped exclamation marks with the previously executed command if the internal variable bang is set.  This command supports vput as documented in Command modifiers, and manages the error number !. A 0 or positive exit status ? reflects the exit status of the command, negative ones that an error happened before the command was executed, or that the program did not exit cleanly, but maybe due to a signal: the error number is ^ERR-CHILD, then.
In conjunction with the vput modifier the following special cases exist: a negative exit status occurs if the collected data could not be stored in the given variable, which is a ^ERR-NOTSUP error that should otherwise not occur.  ^ERR-CANCELED indicates that no temporary file could be created to collect the command output at first glance.  In case of catchable out-of-memory situations ^ERR-NOMEM will occur and Mail will try to store the empty string, just like with all other detected error conditions.
#         The comment-command causes the entire line to be ignored.  Note: this really is a normal command which' purpose is to discard its arguments, not a “comment-start” indicating special character, which means that for example trailing comments on a line are not possible (except for commands which use Shell-style argument quoting).
+         Goes to the next message in sequence and types it (like “ENTER”).
-         Display the preceding message, or the n'th previous message if given a numeric argument n.
=         Shows the message number of the current message (the “dot”) when used without arguments, that of the given list otherwise.  Output numbers will be separated from each other with the first character of ifs, and followed by the first character of if-ws, if that is not empty and not identical to the first.  If that results in no separation at all a space character is used.  This command supports vput (see Command modifiers), and manages the error number !.
?         [Option] Show a brief summary of commands.  [Option] Given an argument a synopsis for the command in question is shown instead; commands can be abbreviated in general and this command can be used to see the full expansion of an abbreviation including the synopsis, try, for example ‘?h’, ‘?hel’ and ‘?help’ and see how the output changes.  To avoid that aliases are resolved the modifier \ can be prepended to the argument, but note it must be quoted.  This mode also supports a more verbose output, which will provide the information documented for list.
|         A synonym for the pipe command.
account, unaccount (ac, una) Creates, selects or lists (an) account(s).  Accounts are special incarnations of defined macros and group commands and variable settings which together usually arrange the environment for the purpose of creating an email account.  Different to normal macros settings which are covered by localopts – here by default enabled! – will not be reverted before the account is changed again.  The special account ‘null’ (case-insensitive) always exists, and all but it can be deleted by the latter command, and in one operation with the special name ‘*’.  Also for all but it a possibly set on-account-cleanup hook is called once they are left, also for program exit.
Without arguments a listing of all defined accounts is shown. With one argument the given account is activated: the system inbox of that account will be activated (as via folder), a possibly installed folder-hook will be run, and the internal variable account will be updated.  The two argument form behaves identical to defining a macro as via define.  Important settings for accounts include folder, from, hostname, inbox, mta, password and user (On URL syntax and credential lookup), as well as things like tls-config-pairs (Encrypted network communication), and protocol specifics like imap-auth, pop3-auth, smtp-auth.
account myisp { set folder=~/mail inbox=+syste.mbox record=+sent.mbox set from='(My Name) myname@myisp.example' set mta=smtp://mylogin@smtp.myisp.example }
addrcodec Perform email address codec transformations on raw-data argument, rather according to email standards (RFC 5322; [v15 behaviour may differ] will furtherly improve).  Supports vput (see Command modifiers), and manages the error number !.  The first argument must be either [+[+[+]]]e[ncode], d[ecode], s[kin] or skinl[ist] and specifies the operation to perform on the rest of the line.
Decoding will show how a standard-compliant MUA will display the given argument, which should be an email address.  Please be aware that most MUAs have difficulties with the address standards, and vary wildly when (comments) in parenthesis, “double-quoted” strings, or quoted-pairs, as below, become involved.  [v15 behaviour may differ] Mail currently does not perform decoding when displaying addresses.
Skinning is identical to decoding but only outputs the plain address, without any string, comment etc. components.  Another difference is that it may fail with the error number ! set to ^ERR-INVAL if decoding fails to find a(n) (valid) email address, in which case the unmodified input will be output again.
skinlist first performs a skin operation, and thereafter checks a valid address for whether it is a registered mailing list (see mlist and mlsubscribe), eventually reporting that state in the error number ! as ^ERR-EXIST.  (This state could later become overwritten by an I/O error, though.)
Encoding supports four different modes, lesser automated versions can be chosen by prefixing one, two or three plus signs: the standard imposes a special meaning on some characters, which thus have to be transformed to so-called quoted-pairs by pairing them with a reverse solidus ‘\’ in order to remove the special meaning; this might change interpretation of the entire argument from what has been desired, however!  Specify one plus sign to remark that parenthesis shall be left alone, two for not turning double quotation marks into quoted-pairs, and three for also leaving any user-specified reverse solidus alone.  The result will always be valid, if a successful exit status is reported ([v15 behaviour may differ] the current parser fails this assertion for some constructs).  [v15 behaviour may differ] Addresses need to be specified in between angle brackets ‘<’, ‘>’ if the construct becomes more difficult, otherwise the current parser will fail; it is not smart enough to guess right.
? addrc enc "Hey, you",<diet@exam.ple>\ out\ there "\"Hey, you\", \\ out\\ there" <diet@exam.ple> ? addrc d "\"Hey, you\", \\ out\\ there" <diet@exam.ple> "Hey, you", \ out\ there <diet@exam.ple> ? addrc s "\"Hey, you\", \\ out\\ there" <diet@exam.ple> diet@exam.ple
alias, unalias [Only new quoting rules](a, una) Define or list, and remove, respectively, address aliases, which are a method of creating personal distribution lists that map a single name to none to multiple receivers, to be expanded after Compose mode is left; the expansion correlates with metoo.  The latter command removes all given aliases, the special name asterisk ‘*’ will remove all existing aliases.  When used without arguments the former shows a list of all currently known aliases, with one argument only the target(s) of the given one.  When given two arguments, hyphen- minus ‘-’ being the first, the target(s) of the second is/are expanded recursively.
In all other cases the given alias is newly defined, or will be appended to: arguments must either be themselves valid alias names, or any other address type (see On sending mail, and non- interactive mode).  Recursive expansion of aliases can be prevented by prefixing the desired argument with the modifier reverse solidus \.  A valid alias name conforms to mta-aliases syntax, but follow-up characters can also be the number sign ‘#’, colon ‘:’, commercial at ‘@,’ exclamation mark ‘!’, period ‘.’ as well as “any character that has the high bit set”.  The dollar sign ‘$’ may be the last character.  The number sign ‘#’ may need Shell-style argument quoting.
[v15 behaviour may differ] Unfortunately the colon is currently not supported, as it interferes with normal address parsing rules.  [v15 behaviour may differ] Such high bit characters will likely cause warnings at the moment for the same reasons why colon is unsupported; also, in the future locale dependent character set validity checks will be performed.
? alias cohorts  bill jkf mark kridle@ucbcory ~/cohorts.mbox ? alias mark  mark@exam.ple ? set mta-aliases=/etc/aliases
alternates, unalternates [Only new quoting rules] (alt) Manage a list of alternate addresses or names of the active user, members of which will be removed from recipient lists (except one).  There is a set of implicit alternates which is formed of the values of LOGNAME, from, sender and reply-to.  from will not be used if sender is set.  The latter command removes the given list of alternates, the special name ‘*’ will discard all existing alternate names.
The former command manages the error number !.  It shows the current set of alternates when used without arguments; in this mode only it also supports vput (see Command modifiers). Otherwise the given arguments (after being checked for validity) are appended to the list of alternate names; in posix mode they replace that list instead.
answered, unanswered Take a message lists and mark each message as (not) having been answered.  Messages will be marked answered when being replyd to automatically if the markanswered variable is set.  See the section Message states.
bind, unbind [Option][Only new quoting rules] The bind command extends the MLE (see On terminal control and line editor) with freely configurable key bindings.  The latter command removes from the given context the given key binding, both of which may be specified as a wildcard ‘*’, so that ‘unbind * *’ will remove all bindings of all contexts.  Due to initialization order unbinding will not work for built-in key bindings upon program startup, however: please use line-editor-no-defaults for this purpose instead.
With zero arguments, or with a context name the former command shows all key bindings (of the given context; an asterisk ‘*’ will iterate over all contexts); a more verbose listing will be produced if either of debug or verbose are set.  With two or more arguments a specific binding is shown, or (re)established: the first argument is the context to which the binding shall apply, the second argument is a comma-separated list of the “keys” which form the binding.  Further arguments will be joined to form the expansion, and cause the binding to be created or updated.  To indicate that a binding shall not be auto-committed, but that the expansion shall instead be furtherly editable by the user, a commercial at ‘@’ (that will be removed) can be placed last in the expansion, from which leading and trailing whitespace will finally be removed.  Reverse solidus cannot be used as the last character of expansion.  An empty expansion will be rejected.
Contexts define when a binding applies, i.e., a binding will not be seen unless the context for which it is defined for is currently active.  This is not true for the shared binding ‘base’, which is the foundation for all other bindings and as such always applies, its bindings, however, only apply secondarily.  The available contexts are the shared ‘base’, the ‘default’ context which is used in all not otherwise documented situations, and ‘compose’, which applies only to Compose mode.
Bindings are specified as a comma-separated list of byte- sequences, where each list entry corresponds to one “key” (press).  Byte sequence boundaries will be forcefully terminated after bind-inter-byte-timeout milliseconds, whereas key sequences can be timed out via bind-inter-key-timeout.  A list entry may, indicated by a leading colon character ‘:’, also refer to the name of a terminal capability; several dozen names are compiled in and may be specified either by their terminfo(5), or, if existing, by their termcap(5) name, regardless of the actually used [Option]al terminal control library.  But any capability may be used, as long as the name is resolvable by the [Option]al control library, or was defined via the internal variable termcap.  Input sequences are not case-normalized, an exact match is required to update or remove a binding.  It is advisable to use an initial escape or other control character (like ‘\cA’) for user (as opposed to purely terminal capability based) bindings in order to avoid ambiguities; it also reduces search time. Examples:
? bind base a,b echo one ? bind base $'\E',d mle-snarf-word-fwd # Esc(ape) ? bind base $'\E',$'\c?' mle-snarf-word-bwd # Esc,Delete ? bind default $'\cA',:khome,w 'echo Editable binding@' ? bind default a,b,c rm -irf / @  # Also editable ? bind default :kf1 File % ? bind compose :kf1 ~v
Note that the entire comma-separated list is first parsed (over) as a shell-token with whitespace as the field separator, then parsed and expanded for real with comma as the field separator, therefore whitespace needs to be properly quoted, see Shell-style argument quoting.  Using Unicode reverse solidus escape sequences renders a binding defunctional if the locale does not support Unicode (see Character sets), and using terminal capabilities does so if no (corresponding) terminal control support is (currently) available.  Adding, deleting or modifying a key binding invalidates the internal prebuilt lookup tree, it will be recreated as necessary: this process will be visualized in most verbose as well as in debug mode.
The following terminal capability names are built-in and can be used in terminfo(5) or (if available) the two-letter termcap(5) notation.  See the respective manual for a list of capabilities. The program infocmp(1) can be used to show all the capabilities of TERM or the given terminal type; using the -x flag will also show supported (non-standard) extensions.