MUSH

Section: User Commands (1)
Updated: Dec 21, 1987
Index Return to Main Contents
 

NAME

The Mail User's Shell - Shell for electronic mail.  

SYNOPSIS

mush [ -n ] [ -v ] [ -s subject ] [ -c cc-list ] [ address-list ... ]
mush [ -n ] [ -i ] [ -r ] [ -C ] [ -N ] [ -S ] [ -1 cmd_help ] [ -d ] [ -f [ folder ] ]
mush [ -n ] [ -i ] [ -r ] [ -C ] [ -N ] [ -S ] [ -1 cmd_help ] [ -d ] [ -u [ user ] ]
mush [ -n ] [ -H[:c] ]
mush [ -n ] [ -t ] [ -T timeout ] [ -1 cmd_help ] [ -2 tool_help ] [ -d ] [ -f [ folder ] ]
mush [ -n ] [ -t ] [ -T timeout ] [ -1 cmd_help ] [ -2 tool_help ] [ -d ] [ -u [ user ] ]  

INTRODUCTION

The Mail User's Shell (Mush) is an interface for sending and manipulating a database of electronic mail messages under the UNIX environment. There are three user interfaces which allow the user to interact with Mush. The default interface is the conventional tty-based line mode similar to command line interpreters such as csh as well as other mailers, such as University of California, Berkeley's, Mail and Bell Lab's System V mailx interface. This mode requires nothing from the terminal in screen optimization and may be run on many different versions of the UNIX operating system.

The text-graphics (curses) interface is reminiscent of the vi visual editor, but is user-configurable to simulate other editors. This interface does not require graphics capabilities of the computer or the terminal on which it is run, but the terminal must have the minimum capabilities required by any visual screen editor.

The window interface for the Sun Workstation utilizes the icon and menu based (mouse selectable) windowing system. This tool (graphics), mode is highly subject to the version of operating system your Sun may be running. While the program works with variable levels of success on earlier versions, it is intended to be run on Sun versions 2.0 and higher. See the BUGS section at the end for more information.

See the corresponding sections for more information on the user interface desired. Most of this manual deals with commands, variables and actions which are common to all three interfaces although some attention is paid to individual characteristics of each interface.

The following command line arguments are understood by Mush:

-C
Enter the mailer in curses mode upon startup.
-c cc-list
The list of Carbon Copy recipients is set on the command line. If more than one address is specified, the entire list should be encased in quotes. This applies when sending mail only. If you are entering the shell, curses mode, or the tool mode, this option is ignored.
-d
Turns on the debugging level to 1. You can change debugging levels from within the shell using the debug command.
-f [ filename ]
The optional filename argument specifies a folder containing mail messages. With no argument, mbox in the current directory (or the variable mbox) is used. If no filename is given, this option must be last on the command line.
-H[:c]
Have Mush display mail headers without entering the shell. See the headers command for information on the :c argument. No colon modifier is equivalent to "-H:a". This option prevents the shell from running, so this option will turn off the -S and -C flags. This option is ignored if the tool mode is in effect.
-i
Forces interactive mode even if input has been redirected to the program. This is intended for remote host mail sessions but also allows the user to redirect "scripts" of Mush commands. See the INITIALIZATION section for information on how to write scripts which deal with mail. Note that this flag is different from the "ignore" flag of UCB Mail.
-N
Enter Mush without displaying any message headers. This argument is passed to the folder command.
-n
No initialization is done on start up. That is, do not source .mushrc or .mailrc files. See the INITIALIZATION section for more information on startup and the significance of these files.
-r
Initialize the folder in Read-Only mode; no modification of the folder is permitted. This argument is passed on to the folder command.
-S
This flag allows the user to enter the shell even if the system mailbox or specified folder is empty or doesn't exist.
-s subject
The subject is set on the command line using this flag. If the subject has any spaces or tabs, the entire subject should be encased in quotes. This applies when sending mail only. If you are entering the shell, curses mode, or the tool mode, this option is ignored.
-T timeout
In the tool mode (Sun only), timeout specifies the length of time (seconds) to wait between each check for new mail. 30 seconds is the smallest time allowed for performance reasons. 60 seconds is the default value.
-t
Use the graphics tool mode (Sun only).
-u [ user ]
The mailbox to use is /usr/spool/mail/user. If the login name for user is not specified, then root is used.
-v
Verbose mode is turned on. This option is passed to the actual mail delivery subsystem internal to your version of UNIX. Some mailers do not have a verbose option, so this flag may not apply to your system (System V, for example). This applies when sending mail only. If you are entering the shell, curses mode, or the tool mode, this option is ignored.
-1 cmd_help
-2 tool_help
Specify alternate locations of help files. These should be full pathnames accessible for reading. This is usually done if a binary copy of Mush has been copied from another machine and the wrong pathnames to the help files cannot be changed.
 

FEATURES

New Mail.

If during a Mush session, new mail arrives for you, it is automatically incorporated into your system mailbox and you are told that new mail has arrived.

In the default line mode, new mail is checked between each command issued. In the curses mode, new mail is checked on each command and is displayed in the bottom line of the screen. In the tool based graphics mode, new mail is checked approximately every minute or by the number of seconds specified by the -T option on the command line.

If you are using your system mailbox as your "current folder," then the new mail is added immediately to your current list of messages and the following information is displayed, to tell you whom the mail is from:


   New mail: (#15) island!argv@sun.com (Dan Heller)

If you are not in your system mailbox, then the new mail will not be added to your list of messages, but you will instead be informed of the new arrival.

If you are using the tool based mode and Mush is closed to an iconic state, then the number of messages in the current folder is displayed on the mailbox icon and the flag on the mailbox will go up.

History.

In the line-mode interface, Mush supports a history mechanism similar to that supplied by csh. A subset of history modifiers are supported to reference previously issued commands and to extract specified arguments from these commands.

Mail Aliases.

Mail aliases are shorthand names for long mail addresses. These are supported in the same manner as UCB Mail supports them. Because Mush has command line history reminiscent of csh, commands which use UUCP's `!' character for user-host and host-host separation should be escaped (preceded by a backslash). This is not necessary in the initialization file (.mushrc) because history referencing is ignored while these files are being sourced. See the INITIALIZATION and LINE-MODE INTERFACE sections for more information on initialization file format and the history mechanism.

Aliases reference normal mailing addresses as well as other aliases. If a loop is detected, then the user will be notified and the message will be forced into the file dead.letter in the user's home directory. The unalias command is used to reverse the effects of the alias command.

Command Line Aliases.

Command aliases are different than mail aliases in that they are used to expand to commands. The usage of command line aliases is similar to that supplied by csh.

Command Pipes.

Mush commands can be "piped" to one another so as to provide output of one command to be used as input to the next command in the pipeline. However, the output of commands is not the "text" that is returned (as it is in csh), but the messages that are affected.

Help.

Mush was designed so that each command or action should not be a mystery. Helping the user understand what to do and how to do whatever he wishes is the goal behind the help facility. For this reason, the help command gives information on both general usage and specific help categories.

In text mode, most help is gotten by typing -? as an argument to a command. Virtually every command has the -? option. When this option is specified, most commands will attempt to read from a help file the necessary information explaining the functionality of the command. If necessary, a pointer to other sources of information will be given to fully explain a concept.

In the curses mode, the `?' key will display a list of the current command-to-key bindings; a keystroke or set of keystrokes correspond directly to a command.

In the tool/graphics mode, this is also available, but more extensive help is provided in the pop-up menus. Pop-up menus can be gotten from virtually anywhere on the screen; press the RIGHT mouse button (the "menu button") and a number of items will appear in a menu. The last command in the menu list will be one labelled "help". Selecting this menu item will display a "help box" in the center of the console and wait for input to remove the box.

Sorting mail.

Mush allows you to sort your mail according to various constraints such as time, status (new, unread, deleted, etc), by author and subject. See the sort command in the COMMANDS section for more information on sorting.

Picking specific messages.

You can select messages that contain unique information, or from messages that have special attributes. You have the option of restricting your search to messages between dates, message numbers, author names and other constraints.  

INITIALIZATION

After the command line arguments have been interpreted, if the argument -n is not given, Mush will read commands from an initialization file that (typically) sets variable values, aliases, command line aliases, and so forth. The default system initialization file is read first and then the user's personal initialization file is read. The system default file is set up by the system administrator and may contain commands which should be set system-wide.

The user's file is determined by first looking for the environment variable MAILRC. If that file isn't found, then the file .mushrc is searched for in the home directory of the user. If that file cannot be found, it will attempt to read the file, .mailrc from the same directory. Finally, if that file cannot be read, no initialization is done and the default values will be in effect.

If the user has no home directory, or permissions prevent read/write access to $HOME, /tmp is used as the home directory. See the home variable under the VARIABLES section.

Once in the shell, the source command may be used to specify a file if you want to read commands from a specific file other than the default. The command saveopts will save all variable settings, aliases, and all other Mush settable attributes, to aid in creating an initialization file. If no filename is given on the command line, the source and saveopts commands choose a file in the manner described above. Saveopts will not overwrite the file if it exists. In such cases, you will be prompted to confirm overwrite. If you confirm overwriting the existing file, remember that existing "if" expressions or other manually entered comments or non variable-setting type commands that previously existed in the file will be lost.

No interactive commands should be called from any initialization file. These commands are not prevented because it is impossible to trace which commands may be UNIX commands that are interactive. The responsibility of not running interactive commands is left to the user. Because the initialization file is read before any messages are read into the program, message filtering commands should not be placed in this file unless you know you're going to re-source the file later as a command.

Initialization File Format. When reading the initialization file, Mush will recognize the `#' character as a comment character. It may be anywhere on a line in the file. When that character is encountered, processing of that line is discontinued to the end of the line. If the `#' is encased in quotes (single or double), then it is not considered a comment. Examples:


   set shell = /bin/csh # set the shell variable
   # this entire line has been commented out.
   set prompt = "Message #%m: " # The `#' is within quotes

The exit command has special meaning in the initialization file. If the command is found, Mush will not exit, but rather, discontinue reading from the file immediately.

There may be "if" expressions within the initialization file to determine certain runtime states of Mush. There are no parentheses allowed and only one boolean expression may be evaluated per line; that is, no "&&" or "||" may be used in expressions. There is currently no support for multiple levels of if-else expressions and embedded "if" expressions are ignored (they are evaluated to TRUE). There must always be an "endif" matching each "if" expression. The statements associated with an "if" expression are never on the same line with the conditional.

Conditional expressions understood include the internal variables, istool, iscurses, hdrs_only, is_sending, and redirect. If istool is true, the program is going to run in the tool mode. If iscurses is true, the program is in or is going to run in the curses mode even though the screen package may not yet have been started. If hdrs_only is true, then the -H flag on the command line has been given. If is_sending is true, then the user is sending mail to a user. This does not imply that the user is not going to be running a shell after the mail is sent. If redirect is true, then input to the program is redirected. The test for redirection tells whether input, not output, has been redirected to the program. The -i option on the command line is required to run the shell if redirect is on. If -i is specified, the value for redirect will be set to false. These are internal variables whose values can not be referenced using the "$variable" method of variable expansion.

The `!' operator may be used to negate expressions, thus,

if !istool

    exit else
    set autoprint endif

means that if you are not running as a tool, stop reading commands from this file. Otherwise, set the autoprint variable.

set hdr_format = "%25f %7d (%l/%c) %25s"
if hdrs_only

    exit endif

This tells the program to set the hdr_format variable and check to see if we're running the program to read headers only. If so, stop reading this file (exit) and continue on with the program. This speeds up runtime quite a bit for those who have lengthy initialization files, because no other shell variables are necessary.

if !iscurses

    set crt = 24 screen = 18 endif

This segment checks to see that we're not running in curses mode, and if not it will set our crt and screen sizes. This is mostly because the curses mode will set those values for us by looking at the size of the screen. Like other interactive commands, the curses command itself should never be called from an initialization file. Doing so will cause terminal settings to be set incorrectly and unpredictable results from there. See the CURSES INTERFACE section for configuring your environment so you enter curses mode each time you run the shell.

String evaluation is allowed in "if" expressions, and the operators "==" and "!=" may be used to determine equality or inequality. Usually, variables are compared with constants for evaluation.

if $TERM == adm3a

    set pager = more else
    set pager = less endif

This segment tests to see if the user's terminal type is "adm3a". If it is, then it sets the pager variable to be the more program. Note that the variable TERM will be gotten from the user's environment if a shell variable is not set already. Otherwise, the pager variable is set to "less". This exemplifies the fact that less normally fails to function correctly for the terminal type "adm3a" so we don't use it.

After sourcing the initialization file, Mush reads all the mail out of the specified folder (the system spool directory if no folder is given) and creates a list of messages. The current maximum number of messages the user can load is set to 1000 by default. The system administrator who configures the program can reset this value higher or lower if you ask nicely. If the user has the sort variable set, then when the current folder's messages have all been read, the messages are sorted according to the value of the variable (see the sort entry under the VARIABLES heading for more information). Each message has a number of message header lines which contain information about whom the mail is from, the subject of the message, the date it was received, and other information about the letter. This information is then compiled into a one-line summary for each message and is printed out in an appropriate manner depending on the interface you're using.

At this point, commands may be input by the user. Lengthy or complex commands can be placed in a file and then executed via the source command; for example, a filtering file, "filter", might contain:

pick -f Mailer-Daemon | save mail_errors
pick -f yukko | delete
pick -s -i thesis | save +thesis_mail
pick -t unix-wizards | +wizmail
update
sort d

Then the first command the user typed might be "source filter" and the following would happen: First, all messages that have "Mailer-Daemon" in the from line will be saved in the file mail_errors. Then, all mail from the user "yukko" will simply be deleted. Next, all mail that has in the subject field "thesis" (case ignored, so "Thesis" would also match) would be saved in the file $folder/thesis. The next command will find all messages that are addressed to the group "unix-wizards" (of which the user is an elite member) and save them in the file $folder/wizmail. Last, the folder will be updated, removing all deleted mail (saved mail may be marked as deleted), and the folder is reread and sorted according to the date of the messages.  

GENERAL USAGE

Because there are three different interfaces available to the user, the tty characteristics (backspace, kill-word, kill-line, redraw line) are simulated identically in all interfaces. When the user has to type something, the 4.2BSD style of tty driver interface is simulated whether you're in the window system, the curses mode, the tty-line mode, and even on System-V machines. This means that backspacing causes a backspace-space-backspace effect (erasing the character backspaced over). The user may reset his tty characteristics using the stty command.

Displaying messages.

Depending on the interface you use, you can display any message in your list of messages as long as the message is not marked for deletion. If the message is marked as deleted, then use the undelete command supplied by the interface you are using. To display a message in line mode, specify a message to be displayed using print, type, p, t, or by typing the message number, that message will be printed on the screen.

In curses mode, move the cursor over the message you want and type a `t' or `p' to read the message. The user may "bind" other keys to call the function which displays messages if `t' and `p' are uncomfortable.

In the graphics mode, move the mouse over the message you wish to be displayed and select the LEFT mouse button. If the message you want is not visible (in the header subwindow), you may type in the message subwindow the number of the message and hit return. That message number will be displayed.

In the line or curses mode, if the message has more lines than the variable crt, then a pager will be invoked to allow the user to page through the message without having it scroll off the screen. The pager used is determined by the variable pager. If that variable is unset, then a default pager will be used. Note that if pager is set, but not to a value, or is set to the value of "internal", then the internal pager is used. The internal pager is very simple; the spacebar displays the next crt lines, carriage return prints the next line, and "q" quits the pager.

In the tool mode, if a message is larger than the size of the message subwindow, the amount of the message viewed is displayed and the user may page through the message via `+' (forward by lines), `-' (backwards by lines), LEFT mouse button (forward by pages), or RIGHT mouse button (backwards by pages). The user may precede the `+' and the `-' keystrokes with a numerical count to specify how many lines to scroll.

An alternative to displaying messages is the top command. This command will print just the top few lines of a message. The number of lines is determined by the variable toplines. If this variable isn't set, top will print a number of lines equal to the value of the variable crt.

Sending mail.

You can send mail using the mail command or by responding to other mail. In either case, when you are sending mail, you are in a mode where everything you type is added to the contents of the message. When you are done typing your message, you can type `^D' to signify the end of the message. If you have the variable dot set, then you can end a message with a `.' on a line by itself.

While you are composing a message, Mush treats lines beginning with the character `~' specially. This is called a tilde escape. For instance, typing "~i" (alone on a line) will place a copy of the "current message" into your message body. It will not include the message headers of the message, just the body of text which composes the message.

Available tilde escapes: [OPTIONAL arguments in square brackets]

~a file
Append message buffer to file name.
~b [bcc list]
Modify blind carbon recipients; otherwise identical to ~t.
~c [cc list]
Modify carbon copy recipients; otherwise identical to ~t.
~E[!]
Erase message buffer. Save the contents of the letter to "dead.letter" (unless the `!' is specified) and then clear the message buffer; the user remains in editing mode. If the variable, nosave is set, then `!' need not be specified.
~e [editor]
Enter the editor. Defaults to variable editor, environment EDITOR, or vi.
~F[!]
Add a fortune [don't add] at end of message.
~f [msg#'s]
Forward mail. The included messages are not indented, but are marked as "forwarded mail".
~H [msg#'s]
Same as ~i, but also include the message headers.
~h
Modify all message headers. Each header is displayed one by one and each may be edited.
~i [msg#'s]
Include current message body (or numbered messages). See the descriptions of the variables indent_str, pre_indent_str, and post_indent_str.
~p [pager]
Page the message body. Defaults to variable pager, environment PAGER, or the default pager set up by the system administrator. This may be the internal pager.
~q
Quit message; save in ~/dead.letter if nosave is not set.
~r file
Read filename into message buffer.
~S[!]
Include [don't include] signature at end of message. The variables, autosign and autosign2 describes the file or string to append to the message. See the VARIABLES section for more information on these variables.
~s [subject]
Modify the subject header. If an argument is given (a new subject), then the subject line is replaced by the new subject line. If none is given, then the subject line is displayed for editing just as in the ~t command.
~t [list]
Change list of recipients ("To" list). If a list is given, this list is appended to the current list. If no list is given, then the current list is displayed and the cursor placed at the end of the list. You can backspace over the stuff in the list or you can append more addresses onto the end of the list as desired. System-V users may only replace the line, retyping it if necessary, to append new users; specifying a list on the tilde line is recommended in this case.
~u
Up one line. If the user made a mistake typing a letter and he has already hit carriage return, he may avoid entering the editor and edit the previous line using ~u. The line is retyped and the cursor is placed at the end allowing the user to backspace over it and retype the line. System-V users should note that if the new line is shorter than it was before the ~u command, the line is padded with blanks to the previous length of the file.
~v [editor]
Enter the visual editor. Defaults to variable visual, environment VISUAL, or vi.
~w file
Write message buffer to file name.
~x
Exit message; don't save in dead.letter.
~$variable
Insert the string value for variable into message. If a boolean variable is listed, nothing is appended regardless of its value.
~:command
Run the Mush command specified by "command". You may not run any command which sends mail. It is inadvisable to change folders at this time since the current message list may be corrupted, but the action is allowed nonetheless to provide flexibility for experienced users.
~~
A line beginning with two escape characters will be unaffected by Mush except that only a single tilde will be inserted into the letter.

The variable escape may be set to describe a character other than `~' to be used as the escape character. When sending mail, the above tilde escapes are available in all three user interfaces.  

LINE-MODE INTERFACE

In the line-mode, the user is given a prompt to which commands are issued and arguments are passed to commands. When the user types at the prompt, each line is parsed and words (or, arguments) are separated into an array of strings. This array, also called an argument vector, is then modified by expanding history references, command line aliases, and variable references. A command line ends when the end of the line is encountered or a pipe (|) or semicolon (;) character are encountered, separating discrete commands.

When a command line has been determined and placed in an argument vector, the first argument in the vector (the "command") is searched for in a list of legal Mush commands. If found, the function associated with that command is called and the rest of the line is passed to that function as command line arguments.

Before commands are called, however, the input the user gives is preprocessed in a style reminiscent of the C-shell (csh). Mush also supports a subset from each of the following aspects of csh: * Command history.
* Command line aliasing.
* "Piping" mechanism to redirect "input" and "output" of commands.

Command history.

The history mechanism remembers commands up to the value of the history variable. If this variable is not set, only the most recent command is remembered. To reference previously typed commands, the `!' character is used in the same manner as in csh. There is a limited implementation of history modification; supported are the argument selectors which reference command line arguments and ":p" (echo, but don't execute the command).

Examples:

!-2:$     two commands ago, last argument.
!3:2-4    the third command, arguments two through four.
!!:p      print the last command in its entirety.

During the sourcing of initialization files (.mushrc), history is not in effect and therefore the `!' character does not cause history expansion. This includes startup of the program and when the command source is issued. UUCP style addresses that contain the `!' character may be given in the initialization file without the need to be preceded by a backslash. However, `!' does need to be escaped if cmd's are used to reference command line arguments.

Command line aliasing.

This feature enables command substitution similar to csh. To be backwards compatible with UCB Mail, the alias command is used for address aliasing. Thus, the command cmd is introduced in place of alias.

Examples:

cmd d delete
cmd t type
cmd dt 'd ; t'
cmd - previous
cmd r 'replysender \!* -e -i'

In the last example, if the user types "r 5", Mush will reply to sender of the fifth message and pass all the other arguments along to the reply command. Note the escaping of the `!' character. This must also be done if set in the initialization file (.mushrc). Had the user not specified a message number on the `r' command line, respond would reply to the "current message" rather than the fifth message.

Piping commands.

"Output" from a command is a message list, not the text in a message. A message list is defined as the set of messages which the user specifies in a command or the messages a command affects after it is through executing. When one command is piped to another, the effect is that the second command will consider only those messages affected by first command. In most cases, Mush is smart enough to know when piping is occurring and may suppress text output that a command might produce.

Examples:


   pick -f fred | save fred_mail

This will find all the messages from "fred" and save them all in the file named fred_mail.


   lpr 4-8 | delete

This will send messages 4, 5, 6, 7, and 8 to the printer and then delete them.


   headers :o | delete

Delete's all old (already read) mail.

Because action is taken on mail messages, not files, metacharacters such as `*' and `?' are not expanded to file names as csh would do. Instead, Mush commands take message lists as arguments (a list references one or messages) to take action upon. To reference message numbers, Mush understands the following special syntax:

*         All messages
^         The first message
$         The last message
.         The current message
N-M       A range of messages between N and M

In the last case, N and M may be * ^ $ . or digits referencing explicit message numbers. The range must be in ascending order.

You can also negate messages by placing the message list inside braces, `{' `}' -- thus, the expression "2-19 {11-14}" references messages 2 through 19 except for messages 11 through 14.

Note that message lists are parsed left to right. Negated messages may be reset by turning them on again later in the argument list. A common error new users make is to specify a negated list without specifying any beginning messages.


   delete { 6 }

In this example, the user attempted to delete all messages except for number 6. He should have specified `*' beforehand. A correct example:


   preserve ^-. { 3 }

Here, the user specifies a valid message list and causes Mush to preserve all messages from the beginning of the list (message 1) to the current message, excluding message 3.

As discussed, after the command line is parsed, the command given is called and the rest of the arguments on the command line are passed to it. If no Mush command has been found that matches the one given, then the variable unix is checked. If it is set, Mush attempts to run the command line as a UNIX command.

If unix it is not set, or if the command could not be found in the user's PATH environment, a message will be printed indicating that the command was not found.

Since no "messages" are affected by UNIX commands, piping is disallowed either to or from such commands. If the user wishes to execute UNIX commands which are to be piped to one another (or use any sort of redirection), the command, sh is provided for such purposes. Since Mush will parse the entire command line, caution should be taken to enclose questionable shell variables or metacharacters with quotes to prevent Mush from expanding them.


 

Index

NAME
SYNOPSIS
INTRODUCTION
FEATURES
INITIALIZATION
GENERAL USAGE
LINE-MODE INTERFACE

This document was created by man2html, using the manual pages.
Time: 06:23:55 GMT, December 12, 2024