argv@zipcode.com (Dan Heller) (04/21/91)
Submitted-by: Dan Heller <argv@zipcode.com> Posting-number: Volume 18, Issue 61 Archive-name: mush/part04 Supersedes: mush: Volume 12, Issue 28-47 #!/bin/sh # do not concatenate these parts, unpack them in order with /bin/sh # file bindings.h continued # if test ! -r _shar_seq_.tmp; then echo 'Please unpack part 1 first!' exit 1 fi (read Scheck if test "$Scheck" != 4; then echo Please unpack part "$Scheck" next! exit 1 else exit 0 fi ) < _shar_seq_.tmp || exit 1 if test ! -f _shar_wnt_.tmp; then echo 'x - still skipping bindings.h' else echo 'x - continuing file bindings.h' sed 's/^X//' << 'SHAR_EOF' >> 'bindings.h' && #define C_PREV_MSG 15L #define C_FIRST_MSG 16L #define C_LAST_MSG 17L #define C_TOP_PAGE 18L #define C_BOTTOM_PAGE 19L #define C_NEXT_SCREEN 20L #define C_PREV_SCREEN 21L #define C_SOURCE 22L #define C_SAVEOPTS 23L #define C_NEXT_SEARCH 24L #define C_PREV_SEARCH 25L #define C_CONT_SEARCH 26L #define C_PRESERVE 27L #define C_REV_SORT 28L #define C_SORT 29L #define C_QUIT_HARD 30L #define C_QUIT 31L #define C_EXIT_HARD 32L #define C_EXIT 33L #define C_UPDATE 34L #define C_FOLDER 35L #define C_SHELL_ESC 36L #define C_CURSES_ESC 37L #define C_PRINT_MSG 38L #define C_CHDIR 39L #define C_VAR_SET 40L #define C_IGNORE 41L #define C_ALIAS 42L #define C_OWN_HDR 43L #define C_VERSION 44L #define C_MAIL_FLAGS 45L #define C_MAIL 46L #define C_REPLY_ALL 47L #define C_REPLY_SENDER 48L #define C_DISPLAY_NEXT 49L #define C_DISPLAY_MSG 50L #define C_TOP_MSG 51L #define C_BIND_MACRO 52L #define C_BIND 53L #define C_UNBIND 54L #define C_MAP_BANG 55L #define C_MAP 56L #define C_MACRO 57L #define C_MARK_MSG 58L #define C_HELP 59L/* THIS MUST BE THE LAST ITEM */ X struct cmd_map { X /* long so glob_flags can be saved in mac_stack */ X long m_cmd; /* the command this is mapped to */ X char *m_str; /* the string user types (cbreak) */ X char *x_str; /* the string executed if a macro */ X struct cmd_map *m_next; }; X #ifdef CURSES X /* X * Pointers to the current active command or macro and to the map list. X * This ought to be handled by having getcmd() return struct cmd_map *, X * but curses_command() depends too heavily on getcmd() returning int. X */ extern struct cmd_map *active_cmd, *cmd_map; X #endif /* CURSES */ X /* This must be OUTSIDE the #ifdef CURSES -- needed in other modes */ extern struct cmd_map *mac_hide; X /* X * Special bracketing recognized within an executing X * macro as surrounding a curses function name X */ #define MAC_LONG_CMD '[' #define MAC_LONG_END ']' #define MAC_GET_STR "getstr" #define MAC_GET_LINE "getline" #define MAX_LONG_CMD 32 X /* X * External declarations for map and map! purposes X */ extern char *c_macro(); extern struct cmd_map *line_map, *bang_map; SHAR_EOF echo 'File bindings.h is complete' && chmod 0644 bindings.h || echo 'restore of bindings.h failed' Wc_c="`wc -c < 'bindings.h'`" test 2970 -eq "$Wc_c" || echo 'bindings.h: original size 2970, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= cmd_help ============== if test -f 'cmd_help' -a X"$1" != X"-c"; then echo 'x - skipping cmd_help (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting cmd_help (Text)' sed 's/^X//' << 'SHAR_EOF' > 'cmd_help' && /* @(#)cmd_help 10/24/88 (Dan Heller) */ X %about% Mush, the Mail User's Shell was conceived, written and performed by X Dan Heller Bart Schaefer argv@zipcode.com schaefer@zipcode.com argv@ora.com schaefer@cse.ogi.edu argv@monet.berkeley.edu argv@uunet.uu.net X Mush is copyright (c) 1986, 1987, 1988, 1989, 1990, 1991 by Dan Heller. X All Rights Reserved. X This software is not in the public domain. It is freely available under the restrictions discussed in the README file accompanying this distribution. X Dan Heller is currently working on his second book, The Motif Programmer's Manual for O'Reilly && Associates. Bart Schaefer recently completed his Ph.D. in Computer Science and Engineering at the Oregon Graduate Institute. Bart and Dan have co-founded Z-Code Software Corporation to produce, among other things, Z-Mail, the successor to Mush. If you like Mush, talk to us about Z-Mail :-). X History: X Mush was created as a friendlier and more versatile replacement for the commonly available UNIX mail utilities. It originated in 1985 as "frankenmail", with strictly a SunWindows interface, but soon expanded to line and curses modes under the demands of excited users. Bart climbed aboard on version 6.0 in October 1987. The current version, 7.2, is the culmination of efforts by Dan, Bart, and numerous contributors from around UseNet: X X Don Lewis Rich Burridge X Bill Randle Bill Petro X Marc Rouleau (MMDF support) Akkana X James Bohem Michael Berman X Mike O'Carroll (DOS ports) David St. Pierre X Kevin Sheehan X and many others who may have been lost or weren't listed for fear of misspelling. X Discussion and support of Mush is available via the newsgroup comp.mail.mush or mailing list mush-users@apple.com, which are one and the same in content. If you cannot get the newsgroup at your site, you can request to join mush-users by sending such a request to mush-users-request@apple.com. %% X %?% X ? [command] X The `?' command gives you a list of legal commands. Most commands accept -? as an option. This provides you with specialized help for that particular command. X If the optional argument is given, help for that command is shown. %% X %ignore% X ignore/unignore [headers] X Use this command to set the message headers you would like not to be printed when you read a message. If no header specified, then a list of all headers currently being ignored is printed. You must specify a header for unignore. X You can set the variable $alwaysignore to force normally ignored headers to be ignored while saving messages, forwarding messages or including messages into message buffers. X See also the variable $show_hdrs. %% X %set% X set/unset [variable [= value]] X With no parameters, set lists all variables and their values. To set a boolean variable (on or off), use: X set variable To set a variable's value to a string, use: X set variable = value X If you want double-quotes or white-space embedded in a string, encase the string in single quotes. If you want single quotes in a string, encase the string in double quotes. X For a list of all variables with special meanings, use: X set ?all For help on a particular one of these variables, use: X set ?variable_name %% X %readmsg% X print [msg_list] X type [msg_list] X top [msg_list] X next [msg_list] X previous [msg_list] X You can read messages in different ways. "type" and "print" display the current message. "top" displays the first N lines of the current message where N is the value of the variable "toplines", or "crt" if "toplines" is not set. "next" advances to the next unread message and print that. "previous" moves back to read the first unread message before the current message. "^" displays the first message, "$" displays the last. X Any of these commands can be followed by a message list, and each message in that list is displayed (or piped to other commands). X See also "help msg_list" and the variable $autoprint. %% X %alts% X alts [hostnames] [*[user]] [!path!user] [user@host] X The alts command sets a list of hostnames on which you have an account. Normally, when you respond to all recipients of mail, your account name is listed as if you wished to send yourself mail. If you don't have metoo set, then your name is removed from the mailing list if the host specified is in the alternates list. Hostnames may be given either as a single name or as a UUCP path (separated by `!' characters). X The special parameter `*' instructs alts to match all hostnames; in that case, only your login name is tested. A user name may be appended to the `*', in which case that name is tested instead of your local login name. A user name at a specific host machine may be specified either with the syntax "user@host" or by beginning the UUCP path to the host with a `!' character. The leading `!' is used to differentiate paths that already end in a user name from those to which your local login name should be appended. %% X %source% X source/saveopts [file] X The source/saveopts commands load/save all variable settings, options, aliases, cmd's, ignored headers ... everything you can set, it loads or saves. The file read or written follows these rules: X 1) If a filename is given, that file is used 2) The file described by the environment variable MAILRC 3) In the user's home directory: .mushrc (if it exists) 4) In the user's home directory: .mailrc (if it exists) X If saveopts is used and the file exists, confirmation is requested before the file is overwritten. %% X %help% X help [item] X Type "help" with no arguments for a list of valid items. %% X %general% This is the general help message. To get help on a specific command, try "command -?". Extended help is given by typing "help item" where item is one of: X path, msg_list, prompt, hdr_format Help with msg_list is highly advisable! X Type "?" to get a list of available commands. Try "? command" to get help on the particular command that you specify. X Use "set ?variable" to get help with specific variables. %% X %path% Whenever "path" is specified, the following syntax is legal besides the normal path addressing scheme used by unix: X ~[user] -- the home directory of specified user (yours by default) X %[user] --/usr/spool/mail/login_name [user_name] (yours by default) X +file --the directory described by `set folder'; file is `file' %% X %msg_list% A "msg_list" references one or more messages. The user specifies a group of messages according to a special syntax. X X * All messages. X ^ The first message. X $ The last message. X . The current message. X N-M A range of messages between N and M, inclusive. X In the last case, N and M may be * ^ $ . or digits referencing explicit message numbers. The range must be in ascending order. X 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 those from 11 through 14. X Commands can be "piped" to one another, because the return value of a command is a msg_list, not text. For example, X pick -f fred | lpr finds all messages "from fred" and send them to the printer. X Commands dealing with more than one message process them in numeric order -- not necessarily the order specified. Thus, the command "save 1-5 9 7 6 file" saves the messages in ascending order, not in the order given. %% X %hdr_format% This variable controls the display of message headers. Use: X set hdr_format="string" to change the header display. The string uses printf style formatting and follows these conventions: X %a address of the author X %c number of characters (bytes) in the message X %d entire date of the message (see "date_received" variable) X %f "From" field (author name and address) X %i the message-id (may or may not be present) X %l number of lines in the message X %M month name of the message X %N day of the month (number) X %n name of the author X %s subject of the message X %t "To" field (recipients) X %T time of the message (see "mil_time" variable) X %u user name (login) of the author X %W day of the week (Sun, Mon, etc.) X %Y year of the message X %y year (last 2 digits only) X \n a newline X \t a tab X A field specifier may be used in any % expansion. Thus, "%20s" displays the first 20 characters of the Subject. No matter what the formatting string, the message number, the status of the message and a '>' (if this is the "current" message) is before any user defined format is printed. %% X %prompt% This variable controls the prompt that mush displays. X set prompt = "string" The "string" follows printf style formatting conventions: X %F full path of the current working folder X %f name (path tail) of the current folder X %m current message number X %n number of new messages X %u number of unread messages X %d number of deleted messages X %t total number of messages X %T current time X %N day of the month (number) (today) X %W weekday name (today) X %M month name (this month) X %Y year (this year) X %y year (last 2 digits only) X %$ introduces variable name X \n newline X \t tab X The special sequence %$ must be followed by the name of a variable. The value of that variable is inserted into the prompt at the time the prompt is displayed. When setting a %$variable sequence in your prompt, be sure to enclose the string in single quotes ('') to prevent the shell from expanding the variable at that time. %% X %preserve% X preserve [msg_list] X The "preserve" command marks messages to be saved in your system mailbox. Unless explicitly preserved, all mail that you read is saved at quit time in ~/mbox (or the file specified by $mbox). Deleted messages are preserved only if first undeleted (see "delete -?"). When a message is preserved, the `P' status bit appears in the header summary display for that message. X The "unpreserve" command reverses the effect of "preserve". X Setting the boolean variable $hold is equivalent to preserving each message as you read it, except that no `P' status is set. %% X %mark% X mark [-[A|B|C|D|E]] [msg_list] X unmark [msg_list] X The "mark" command places a tag on messages that you wish to reference later. If no argument or a msg_list only is given, the mark is temporary and is not saved when the folder is updated. The command "headers -H:m" (abbreviated as ":m") can be used to reference all messages having this temporary mark. X A "priority" may be set on messages by specifying a `-' followed by a letter in the range A through E. The "sort" and "pick" commands can be used to order or select messages according to their priorities. Message priority is saved across folder updates. X Messages may have both a temporary mark and a priority, but may not have more than one priority. The presence of a temporary mark is shown by a `+' character immediately following the message number in the "headers" command display, while the priority letter is displayed in the same place if the message unmarked but prioritized. X The "unmark" command removes temporary marks only. To remove the priority of a message, do not specify a priority: X X mark - [msg_list] X See also the commands "set", "sort", "pick" and "headers". %% X %save% X save/write/copy [-s|-S|-a|-A] [-f] [msg_list] [filename] X If no filename is specified, ~/mbox (or the value of the variable "mbox") is used. Save and write append the message to the file if it already exists. Specifying -f overwrites the file (e.g., erasing it first). X To save messages to a filename beginning with a digit, escape the filename with a backslash (\). X The "write" command writes message without the headers (message body only). Save and write both mark messages for deletion unless $keepsave is set. The "copy" command is identical to "save" except that messages are not marked for deletion (identical to having the variable "keepsave" set). X The -s and -S options save messages to files named by the subject of the message. If more than one message is specified, then the message subject of each message is used. If -S is specified, then the subject of the first message is used for all messages. Spaces and forward slashes (/) are converted to underscores (_). X The -a and -A options save messages by author's login name. %% X %lpr% X lpr [-n] [-h] [msg_list] X Send a message to the printer. The options are: X -n print body of message only (no headers) X -h do not print ignored headers X -Pxx print on printer xx X The variable $printer can be used to specify a default printer; for example, "set printer=lp" is the same as always using "-Plp". The variable $print_cmd can be used to specify a program other than "lpr" to use for printing. X NOTE: Some systems require that the printer name be introduced by "-d" rather than "-P". Mush may have been configured so that both -P and -d will produce the correct result, but if an error occurs, try the other option. X See also the variable $alwaysignore. %% X %mail% X mail [mail-flags] [recipients] X Compose and send a mail message. The possible flags are: X -b bcc-addrs set blind-carbon-copy recipients X -c cc-addrs set carbon-copy recipients X -e immediately enter editor (autoedit) X -E edit outgoing headers X -f [msg-list] forward msg-list (not indented) X -F add fortune to the end of message X -h file read file as prepared draft (with headers) X -H file read file as prepared text (without headers) X -i [msg-list] include msg-list in letter X -I [msg-list] include msg-list with headers in letter X -s [subject] prompt for or set subject X -u do not append signatures and fortunes X -U send draft immediately (use with -h or -H) X -v verbose (not available on some systems) X The -f option adds new headers and automatically sends the indicated messages to the list of recipients unless -E or -e is also given. The -I and -i options copies the indicated messages into the text of your letter, surrounded by the text of variables pre_indent_str, indent_str, and post_indent_str. X The -h option reads a draft file, which should already include message headers. The -H option reads a text file, which should NOT include headers. If the -U option is also given, the draft is sent immediately. X See also the variables $ask, $askcc, $autoedit, $autoinclude, $autosign, $autosign2, $dot, $edit_hdrs, $escape, $fortune, $fortunates, $logfile, $record, $no_expand, $no_hdrs, $realname, $sendmail, $verbose, $verify, and $wrapcolumn. %% X %respond% X replysender/replyall [msg-list] [-r path] [mail-flags] [recipients] X The "replysender" command replies only to the sender of a message, whereas "replyall" responds to everyone on the To: and Cc: lines of the message. X The command "reply" is identical to "replysender". X If a message list is indicated, then each message on the list is replied to in the same manner. If -r is specified with a host or path (uucp-style), then each address in the list is routed via this path. This overrides the value of auto_route (see man page). X The address of the author is obtained from certain headers in his message to you. Unless you specify otherwise, mush searches for the headers Reply-To: Return-Path: and From:. You can override these values by setting the variable reply_to_hdr. X X set reply_to_hdr = "sender reply-to return-path from_" X This example shows that mush searches (in order) for the headers listed in the reply_to_hdr variable. If one header isn't found, then mush looks for the next in the list. If none of the headers in the list are found, the default headers (mentioned above) are searched. The last header listed in the example is the special "From " header. See the man page for more details. X Type "mail -?" for information on legal mail flags. X See also the variables $auto_route, $domain_route, $in_reply_to, $known_hosts, $metoo, $reply_to_hdr, and those listed by "mail -?". %% X %sort% X sort [-i] [-r|a|d|l|R|s|S] X X -i ignore case in alphabetical sorts X -r reverse order of next criteria X X -a by author (alphabetical) X -d according to date X -l by length (size in characters, not lines) X -p by priority (marks) X -R by subject including Re: X -s by subject ignoring Re: (alphabetical) X -S by status X Any combination of the options can be given. Each comparison proceeds from left to right through the list of criteria, stopping when an ordering has been determined or no criteria remain. The optional -r flag reverses the order of the next comparison specified. Example: X X sort -i -a -r -d X The above sorts by author first, ignoring case, and then sorts by reverse date (most recent first) for each author. The -r option can be given once for each criterion and applies only to the first criterion that follows it. Giving -r twice in succession (-r -r) does NOT negate the reversal! Whatever option follows the rightmost -r has its sense reversed. X Unlike -r, the -i option is recognized at most once and applies to all alphabetical sorts in the list of criteria. X By default (no parameters), sort orders messages by status: New, unread messages are first, followed by preserved messages and finally the deleted messages are placed at the end. If -r is the only flag given, the status order is reversed. X If the $date_received variable is set, sorting by date is done using the date you received the message. Otherwise, messages are sorted by date sent by the original author. X See also the variable $sort. %% X %pick% X pick [+<num>] [-<num>] [-r msg_list] [-x] [-i] [-h hdr] [-f|s|t] X [-d [-][date]] [-ago [+|-] [n days] [n weeks] [n months]] X [-p priority] [[-e] <pat>] X Search for patterns within messages. Entire messages are searched for <pattern> unless -f, -h, -s, or -t is specified. Only one of -d, -f, -h, -s, -t and -ago can be specified; no pattern is used with -d and -ago; and -x may not be used in conjunction with +<num> and/or -<num>. X X +<num> return only the first <num>ber messages matched X -<num> return only the last <num>ber messages matched X -x return all the messages which do NOT match X -e remaining arguments are the <pat> (`e'xpression) X -f match pattern in the "From:" field (author) only X -s match pattern in the "Subject:" header only X -t match pattern in the "To:" field only X -h hdr match pattern in specified header field only X -i ignore case of letters in when matching X -r msg_list restrict the range of messages search to msg_list X -d select messages sent on [+ after] [- before] date X A "date" is of the form: [+-][month]/[date[/year]] X Omitted fields default to today's values. Examples: X pick -d 4/20 messages on Apr 20, this year X pick -d -/2/85 on or before the 2nd, this month, 1985 X pick -d +5/4 on or after May 4, this year X pick -d / finds today's messages only X At least one `/' char must be used in a date. There is X no strong date checking; 2/30 would be considered valid. X -ago select messages relative to the current date X Date formats for "ago" are more verbose than for -d; see X the manual page for details. X -p [A-E] select messages with specified priority X Multiple -p flags may be used to search for several X priorities at once. X Examples: X Find the first 5 messages with the subject "Telephone Message": X pick +5 -s Telephone Message X Find the first 2 messages of the last 4 that are to "mush-users": X pick -4 +2 -t mush-users X Find those among messages 1 to 10 that are 2 months or more old: X pick -r 1-10 -ago -2m X Find messages that are 1 week old or newer: X pick -ago +1w X Find messages that contain "-request" in the Resent-From field: X pick -h resent-from -e -request X A description of the pick operation is printed before the search is performed, unless the value of the variable $quiet contains the field "pick", or pick is piped to another mush command. %% X %alias% X alias [name [namelist]] X Options for alias: X alias print all namelists X alias name print namelist associated with name X alias name namelist set "name" to the value of namelist X unalias namelist unalias names in namelist X A "namelist" consists of one or more addresses. An address may be a name already set to another list, a valid user, a file or a program. Filenames must be full pathnames, i.e., they must begin with a '/' (or with a ~, which expands to some home dir). A "program" must start with a pipe symbol and be encased in quotes: X X "|program_name" X The command "expand" fully expands addresses (including sublists) associated with the given alias. X See also the variable $no_expand. %% X %from% X from [+|-] [msg-list] [pattern] X With no parameters, "from" displays the current message's header line. If given a message list, "from" displays the headers of the listed messages. X The special parameters `-' and `+' can be given to move the current message pointer to the previous or next message respectively, while also printing that message's header. X If a message list was given in addition to `-' or `+', then the current message pointer is set to the first or last message, respectively, in the message list given. X If a pattern is given, that pattern is searched for in the From: header of the message. If both a message list and a pattern are given, the pattern search is restricted to the listed messages. X Examples: X X from - 10-30 {16} displays the headers of messages 10 through 30 except for message 16 and set the current message pointer to 10. X X from + Dan displays the headers of all messages that contain "Dan" in the author's name and set the current message pointer to the last one of that kind in the list. X X from + displays the header of the message after the current message and increment the current message pointer to that message. X See also the "headers" command and "help hdr_format". %% X %my_hdr% X my_hdr [header[: string]] X This command is used to set, unset or view your personalized message headers. These headers are included in all your outgoing mail. X Options for my_hdr: X my_hdr show all headers X my_hdr header show value of header X my_hdr header: string set header to string X un_hdr header unset header X Note that there is no space between the header name and the colon in the third form of the command. %% X %fkey% X fkey [<sequence> [command]] X unfkey <sequence> X This command is used to make function key settings in Suntools (graphics) mode. When run as a tool (-t on command line), choose the Options item, and the "function key" menu option. X The unfkey command removes the setting for a given string. %% X %cmd% X cmd [name [value]] X This function is used to establish command aliases; cmd's are just like aliases in the C-shell. Options are: X cmd view all commands X cmd command show value of command X cmd command value set command to value X uncmd command unset command X The value must be quoted if it is to contain command separators such as `;' or `|'. X If you want to reference history commands within a cmd, escape the ! with a backslash. For example: X X cmd r 'replysender \!* ; delete -t' X causes "r" to reply using whatever parameters you have given on the command line and then delete that message and print the next message (-t parameter to "delete"). %% X %headers% X headers [+|-|N] [[-H]:c] X + print the next screenful (or use the 'z' command). X - print the previous screenful (or use 'z-' ). X N print a screenful starting at message number N. X -H:c where `c' is one of X a all messages (mostly for the mush startup option -H:c) X d deleted messages X m marked messages X n new messages X o old messages X p preserved messages X r replied-to messages X s saved messages X u unread messages X The "headers" command prints out a screenful of headers. Deleted messages are not normally shown; set "show_deleted" to include deleted messages. X The command ":c" is equivalent to "headers -H:c". The -H can be omitted, i.e., "headers :c" also works. X See also "help hdr_format". %% X %folder% X folder [-N] [-n] [-r] [%[user]|#|&|file] X X -N do not display the list of headers X -n do not update the current folder before changing X -r read only mode (cannot write changes to new folder) X %[user] change to /usr/spool/mail/[user] (you by default) X # change to folder accessed previous to current folder X & change to "mbox" -- default is $mbox or ~/mbox X The "folder" command changes the current folder; with no parameters, it prints the name of the current folder. For compatibility with older versions, the single character `!' is equivalent to -n. X "Folder" treats the characters `+' and `~' as metacharacters when they are the first character of a file name. `~' is expanded to the name of the user's home directory, or to another user's home if it is given as "~username" (no `/' between the `~' and the name). `+' is expanded to the user's folder directory ("~/Mail" or the value of $folder); no `/' is required between `+' and the file name, so both "+file" and "+/file" refer to the same file. X The "update" command updates the current folder. In this case, only the -N and -r options are recognized; "update -r" changes the current folder to read only mode AFTER updating it. X See also the variable $folder. %% X %quit% X quit/exit X These commands end a mush session. "quit" updates your mailbox; if new mail has come in, you are told so and given an option whether to really quit or not. "exit" terminates mush neither updating your mailbox nor checking for new mail. %% X %ls% X ls [options] X The "ls" command is exactly like the UNIX command "ls". All parameters are the same. The "folders" command is equivalent to doing "ls -FR $folder" from the Mush prompt. %% X %shell% X sh [command] X If a "command" is given, that UNIX command is executed under the Bourne shell. If no command is specified, then an interactive shell is started. The environment variable SHELL or the local mail shell variable $shell describes the shell to invoke. If none is set, then the default shell is defined by the system administrator (currently set to csh). X Users on systems with job control probably have little use for the sh command. %% X %stop% X stop X The stop command sends a stop signal to the mail shell. It is equivalent to your tty job-control stop character (often ^Z). Since the mush shell never needs to be exited, the command 'q' may be "cmd"ed to "stop;await" and csh users may have X alias mail %mush to bring mush into the foreground rather than having to invoke it again. New mail is then read into the shell automatically and much time and energy is saved. %% X %curses% X curses X The curses-based interface for Mush does not require a graphics display, but does require a terminal which can handle upline cursor movement capabilities. All commands are one or two keystroke commands and are executed as soon as the key is typed. X For a list of current key-to-command bindings, use the "bind" command (defaults to 'b' in curses mode). X See also the variable $curses_help. %% X %bind% X bind [<sequence> <curses-command> [<parameters>]] X unbind <sequence> X Binding is done for the curses interface only. It allows the user to bind keystrokes or key sequences to curses-interface commands. You cannot bind keystrokes to regular mush commands using bind. X A bound key-sequence (input by the user) is converted into the curses command it is bound to. For a list of all curses commands, issue the "bind" command and follow the instructions to get a list. Currently, parameters are ignored for all curses commands except the special command "macro". X When specifying sequences, you may enter almost anything at the keyboard that you want to type. This includes most control characters. A special syntax is provided to specify control characters if you wish to set up default key bindings in your initialization file without using real control characters. X To bind keystrokes that are control characters in the initialization file, you must use the notation "\CX" where "X" is an upper-case letter representing the control key you want to use. "\CN" would be control-N; "\n" is carriage return. You may not bind keyboard generated signals; for most users, those key sequences are control-C and control-\. For users with job control, the suspend characters (usually control-Z and control-Y) are also ignored. X Trying to bind a key sequence which prefixes another sequence is an error and the user is warned that the longer binding does not work. The binding does take place, however, because it is possible to unbind the shorter sequence, thus validating the longer sequence. X The special curses command "macro" allows a string to be executed just as if the user typed it directly. Issue the "bind-macro" command for more details. X Bindings are removed with the "unbind" command. %% X %msg_flags% X flags [[+|-] [flag-bits]] [msg-list] X Any sensible combination of these flag-bits may be used: X D deleted X f forwarded X N new X O old X P preserved X p printed X R read X r replied-to X S saved X U unread X This command displays the status of messages by default. If a msg-list is specified, it tells which bits of the message are set. If any (one or more) of the bits are given and no + or - modifier is specified, then the status of each message in the list is set to that status absolutely (other status flags are lost). However, if a + or - is specified, then the status is modified for that bit to on (+) or off (-). X If no list is given, the current message is used. %% X %setenv% X setenv VARIABLE [value] X Variable names may be any string, but traditionally environment variables are all upper case. If no "value" is specified, then the variable name is set to an empty string. If the value contains spaces, you should enclose the string in quotation marks. Use printenv to print a list of all your environment variables. %% X %unsetenv% X unsetenv VARIABLE X You must specify one and only one variable to unset in your environment variable settings. Use printenv to print a list of all your environment variables. %% X %printenv% X printenv [VARIABLE] X Display the entire current environment, or the value of the specified environment variable. X Also see "setenv" and "unsetenv". %% X %edit_msg% X edit [msg_list] X The "edit" command lets you edit messages in your folder. The editor used is determined by the variable $editor, the environment variable EDITOR, the variable $visual and the environment variable VISUAL in that order. If none of those variables are set, the default visual editor is used. The "v" command is the same as "edit" but tests only $visual and VISUAL. X When editing messages, be careful not to remove certain message headers such as Date:, From:, or any others that look important. If you remove or change something you shouldn't have, you are notified and the temporary file used to edit the message is not removed. %% X %bind-macro% X bind-macro [<sequence> [<expansion>]] X The "bind-macro" command allows you to set macros in curses mode, so that one keystroke (or a few) acts as though you had typed a longer sequence. Using "bind-macro" is equivalent to specifying the "macro" special command as a parameter to the "bind" command. X Given no parameters, "bind-macro" lists all current curses mode macros. Given only a <sequence>, it shows the current binding for that sequence. Given both a <sequence> and an <expansion>, it creates a macro such that, when the <sequence> is typed in curses mode, the effect is the same as if the <expansion> had been typed instead. X The same format for control characters that is used for the "bind" command may be used in both the <sequence> and the <expansion>, i.e., X \Cx control-x (where x is a capital letter) X \E the escape character (\C[ does NOT work!) X \n a newline (other C-style escapes also work) X Example: X bind-macro F [folder]+record\n X If you are in curses mode and hit the F key, then the curses mode command "folder" executes and +record (followed by a carriage return) is entered as if you typed it. X Macros are removed with the "unbind" command, see "bind -?". X Also see the "map" and "map!" commands. %% X %map% X map [<sequence> [<expansion>]] X unmap <sequence> X The "map" command allows you to use one keystroke (or a few) and have it act as though you had typed a longer sequence. X Given no parameters, "map" lists all current line mode macros. Given only a <sequence>, it shows the current binding for that sequence. Given both a <sequence> and an <expansion>, it creates a macro such that, when the <sequence> is typed in line mode, the effect is the same as if the <expansion> had been typed instead. X The same format for control characters that is used for the "bind" command may be used in both the <sequence> and the <expansion>, i.e., X \Cx control-x (where x is a capital letter) X \E the escape character (\C[ does NOT work!) X \n a newline (other C-style escapes also work) X Example: X map & print\n X If you are not in curses mode and hit the & key, then mush acts as if you typed the word "print" and hit carriage return. X To type a character without having the mapping expanded, precede the character with a backslash (\). X Mappings are removed with the "unmap" command. X Also see the "map!" and "bind" commands. %% X %map!% X map! [<sequence> [<expansion>]] X unmap! <sequence> X The "map!" command allows you to set macros in message composition mode, so that one keystroke (or a few) acts as though you had typed a longer sequence. map!'s take effect regardless of whether you started the letter from curses mode or line mode. X Given no parameters, "map!" lists all composition mode macros. Given only a <sequence>, it shows the current binding for that sequence. Given both a <sequence> and an <expansion>, it creates a macro such that, when the <sequence> is typed in message composition mode, the effect is the same as if the <expansion> had been typed instead. X The same format for control characters that is used for the "bind" command may be used in both the <sequence> and the <expansion>, i.e., X \Cx control-x (where x is a capital letter) X \E the escape character (\C[ does NOT work!) X \n a newline (other C-style escapes also work) X Example: X map! ! <BANG> X If you are typing in a letter regardless of which interface you use and you hit the ! key, then mush reacts as if you typed the keys "<BANG>". X To type a character without having the mapping expanded, precede the character with a backslash (\). X Mappings are removed with the "unmap!" command. X Also see the "bind" and "map" commands. %% X %eval% X eval [-h|-p] args ... X This command causes its arguments to be re-parsed and then executed as a mush command. Example: X X set initprompt='"$hostname:$cwd "' X eval set prompt=$initprompt X If the -h flag is given, then eval looks for formatting parameters as defined for the variable $hdr_format, and expands the formats for the "current" message before executing the command. Example: X X eval -h pick -f %f X finds all messages from the same author as the current message. X If the -p flag is given, then eval expands formatting parameters as as defined for the variable $prompt. The -h and -p flags may not be used together in the same eval. %% X %pipe_msg% X pipe [-p pattern] [msg-list] [unix-command] [cmd-args] X This command is used to send a message to a unix command. The command takes its input from the message(s) passed to the pipe command. By default, the entire message (including headers) is sent. Ignored headers (see "ignore -?" and "set ?show_hdrs") can be suppressed by setting the variable $alwaysignore. X You can pipe (|) messages to this command rather than give a msg-list, but if no msg-list is given and there is no pipe, the current message is used. The unix-command is executed via "sh", so csh aliases may not be used. X If invoked with a capital letter (Pipe), only the bodies of the messages are fed to the unix-command -- all headers are omitted. X A pattern can be specified to indicate which line should start the lines that are sent to the unix command. The pattern must match literally (no regular-expressions) at the beginning of a line. Once the pattern is found, that line and all succeeding lines are sent to the unix command. X If the unix-command is omitted, then /bin/sh is used and the pattern searched for is "#!". Therefore, "pipe" with no arguments can be used to treat a message as a shell script. X Examples: X pipe patch -- send the current message to "patch" X pipe -p %! lpr -- send the message to a postscript printer X pipe 2 7 more -- send messages 2 and 7 through "more" X 1 | Pipe nroff -- send the body of message 1 to "nroff" %% X %merge% X merge [-N] folder-name X The contents of the specified folder are read into the current folder. If -N is not specified, a header summary is printed for each message read (see "headers -?"). X A list of all the merged messages is returned for use in pipes. %% X %echo% X echo [-n] [-h | -p] args X Echo simply echoes the parameters to the command back to the user. X If the -n flag is given, then no newline is appended. If the -h flag is given, then echo looks for formatting parameters as if the "from" command were given on the "current" message. If the -p flag is given, then echo looks for formatting parameters as if your prompt were changed temporarily. X Examples: X echo -h This message is from %a and is dated %d might produce: X This message is from island!argv and is dated Dec 14, 1988. X X echo -p There are %n new messages to read in %f. might produce: X There are 5 new messages to read in /usr/spool/mail/argv. X Note that -h and -p cannot be specified together. %% X %undigest% X undigest [-m] [-p pattern] [msg_list] [filename] X A "digest" is a mail message which is a collection of other mail messages mailed to a "moderator" by other users. The moderator compiles all the messages into a folder and sends the result to all the subscribers of the mailing list. The undigest command disassembles the entries into the set of messages which comprises the digest. X The -m option merges these messages into the current folder. Otherwise, if a filename is specified, a new folder is created and the user can change folders to read the messages separately. X The -p option specifies an alternate pattern to use as the digest article separator. The pattern must match literally at the beginning of a line. The default pattern is "--------" (eight hyphens). X If a message list is specified, each digest is disassembled to the same filename (if given). If no filename is given and the user did not request a merge, then a folder is created based on the subject of the digest. %% X %await% X await [-T delay] X Instructs the shell to wait for new mail to arrive. New mail is checked every 30 seconds by default; a different delay can be specified by using the -T option. X If this command is used in a pipe, its output is its input plus the list of new messages that have arrived. For example, to show the headers of all new messages, and set the current message to the first new message: X X await | from - X The await command terminates only when new mail arrives or a keyboard interrupt is generated. %% X %cd% X cd [directory] X Change the current working directory to the specified directory, or to the user's home directory if none was given. X If the variable $cdpath is set to a list of directory names, and the argument directory is not an absolute path, mush searches the cdpath directories in the order given for the new directory and changes to the first one found. NOTE: The current directory "." is always searched first, before any directory in $cdpath. %% X %pwd% X pwd X Prints the current working directory. The variable $cwd also holds the current working directory unless reset by the user. %% X %delete% X delete/undelete [msg-list] X The "delete" command marks the listed messages as deleted. If no message list is given, the current message is deleted. X Deleted messages are not shown in the header summary display except in curses mode and when the variable $show_deleted is set. Deleted messages are ignored by the "pipe" command and by the commands that display messages (see "print -?"), but most other commands include all messages whether deleted or not. X Deleted messages are lost forever when the folder is updated (by the "update" command, by changing folders without the "!" flag, or by exiting with "quit"). Messages can be recovered by the "undelete" command at any time BEFORE the folder is updated. X See also the variable $show_deleted. %% X %history% X history [-h] [-r] [number] X Display the command history that mush has recorded, as in csh. Option -h suppresses the history numbers, and option -r shows the history in reverse order (most recent first). If a number is given, that many commands of history are displayed. X The number of commands that mush records is controlled by the variable $history. If $history is not set, mush saves only the previous command (equivalent to history=1). X The basic forms of history reference are (N is a number and str is any string): X X !str most recent command beginning with str X !?str? most recent command containing str X !N command N from the history list X !-N command N previous to the current one X !! previous command (same as !-1) X !$ last word of previous command X !* all arguments of previous command X Modifiers (H can be str, ?str?, N or -N, n is a number or $): X X !H:$ last word of referenced command X !H:n n'th word of referenced command X !H:n-m n'th through m'th words of command X !H:-n word 0 (command name) through n of command X !H:* all arguments of command (same as !H:1-$) X !H:n- word n through next-to-last word X !H:p print but don't execute command X X !{R}str append str to reference R (R is any form above) X It is not currently possible to combine :p with any of the other modifiers. X Also see the variable $nonobang. %% X %folders% X folders X List the files in the directory described by the variable $folder. These files are assumed to be folders of mail messages that can be read in by the "folder" command (see "folder -?"). X Also see the "ls" command. %% X %stty% X stty [options] X The "stty" command is equivalent to the UNIX command "stty". All options are the same. Some settings are temporarily changed while mush is running, but are restored when mush exits. %% SHAR_EOF chmod 0644 cmd_help || echo 'restore of cmd_help failed' Wc_c="`wc -c < 'cmd_help'`" test 43712 -eq "$Wc_c" || echo 'cmd_help: original size 43712, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= command2.c ============== if test -f 'command2.c' -a X"$1" != X"-c"; then echo 'x - skipping command2.c (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting command2.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'command2.c' && /* @(#)command2.c (c) copyright 1991 (Dan Heller) */ X #include "mush.h" X /* X * Note that all of the routines in here act upon and return 0 or -1. X * if -1, then the main loop will clear message lists. X */ X /* This is the bottom half of commands.c */ X /* X * Do an ls from the system. X * Read from a popen and use wprint in case the tool does this command. X * The folders command uses this command. X */ ls(x, argv) int x; char **argv; { X register char *p, *tmp; X char buf[128]; X register FILE *pp; X X if (*++argv && !strcmp(*argv, "-?")) X return help(0, "ls", cmd_help); X p = buf + strlen(sprintf(buf, "%s -C", LS_COMMAND)); X for ( ; *argv; ++argv) { X x = 0; X if (**argv != '-') X tmp = getpath(*argv, &x); X else X tmp = *argv; X if (x == -1) { X wprint("%s: %s\n", *argv, tmp); X return -1; X } X *p++ = ' '; X p += Strcpy(p, tmp); X } X if (!(pp = popen(buf, "r"))) { X error(buf); X return -1; X } X (void) do_pager(NULL, TRUE); X while (fgets(buf, 127, pp) && do_pager(buf, FALSE) != EOF) X ; X (void) pclose(pp); X (void) do_pager(NULL, FALSE); X return 0; } X /*ARGSUSED*/ sh(un_used, argv) int un_used; char **argv; { X register char *p; X char buf[128]; X X if (*++argv && !strcmp(*argv, "-?")) X return help(0, "shell", cmd_help); X if (!(p = do_set(set_options, "shell"))) X p = DEF_SHELL; X if (!*argv) X if (istool) { X print("You can't run an interactive shell from tool mode (yet)."); X return -1; X } else X (void) strcpy(buf, p); X else X (void) argv_to_string(buf, argv); X if (!istool) X echo_on(); X (void) system(buf); X if (!istool) X echo_off(); X return 0; } X #ifdef SIGSTOP stop(argc, argv) int argc; char **argv; { X if (istool) X print("Not a tool-based option."); X if (argc && *++argv && !strcmp(*argv, "-?")) X return help(0, "stop", cmd_help); X if (kill(getpid(), SIGTSTP) == -1) X error("couldn't stop myself"); X return 0; } #endif /* SIGSTOP */ X extern char **environ; static int spaces = 0; X Setenv(i, argv) int i; char **argv; { X char *newstr; X X if (i < 2) X return Printenv(i, argv); X else if (i > 3 || !strcmp(argv[1], "-?")) X return help(0, "setenv", cmd_help); X X if (i == 3) { X if (newstr = malloc((unsigned) (strlen(argv[1]) + strlen(argv[2]) + 2))) X (void) sprintf(newstr, "%s=%s", argv[1], argv[2]); X } else { X if (newstr = malloc((unsigned)(strlen(argv[1]) + 2))) X (void) sprintf(newstr, "%s=", argv[1]); X } X if (!newstr) { X error("setenv: out of memory"); SHAR_EOF true || echo 'restore of command2.c failed' fi echo 'End of part 4' echo 'File command2.c is continued in part 5' echo 5 > _shar_seq_.tmp exit 0 exit 0 # Just in case... -- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM Sterling Software, IMD UUCP: uunet!sparky!kent Phone: (402) 291-8300 FAX: (402) 291-4362 Please send comp.sources.misc-related mail to kent@uunet.uu.net.