home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-05-06 | 54.5 KB | 1,613 lines |
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # If this archive is complete, you will see the following message at the end:
- # "End of archive 4 (of 19)."
- # Contents: mush/cmd_help mush/init.c
- # Wrapped by argv@turnpike on Wed May 2 13:59:21 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'mush/cmd_help' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'mush/cmd_help'\"
- else
- echo shar: Extracting \"'mush/cmd_help'\" \(39046 characters\)
- sed "s/^X//" >'mush/cmd_help' <<'END_OF_FILE'
- X/* @(#)cmd_help 1.4 10/24/88 (Dan heller) */
- X
- X%?%
- X ? [command]
- X
- XThe `?' command will give you a list of legal commands. Most
- Xcommands accept -? as an option. This will give you specialized
- Xhelp with that particular command.
- X
- XIf the optional argument is given, help for that command is shown.
- X%%
- X
- X%ignore%
- X ignore/unignore [headers]
- X
- XUse this command to set the message headers you would like not
- Xto be printed when you read a message. If no header specified,
- Xthen a list of all headers currently being ignored is printed.
- XYou must specify a header for unignore.
- X
- XYou can set the variable $alwaysignore to force normally
- Xignored headers to be ignored while saving messages, forwarding
- Xmessages or including messages into message buffers.
- X
- XSee also the variable $show_hdrs.
- X%%
- X
- X%set%
- X set/unset [variable [= value]]
- X
- XWith no parameters, set lists all variables and their values.
- XTo set a boolean variable (on or off), use:
- X set variable
- XTo set a variable's value to a string, use:
- X set variable = value
- X
- XIf you want double-quotes or white-space embedded in a string,
- Xencase the string in single quotes. If you want single quotes
- Xin a string, encase the string in double quotes.
- X
- XFor a list of all variables with special meanings, use:
- X set ?all
- XFor help on a particular one of these variables, use:
- X set ?variable_name
- X%%
- X
- X%readmsg%
- X print [msg_list]
- X type [msg_list]
- X top [msg_list]
- X next [msg_list]
- X previous [msg_list]
- X
- XYou can read messages in different ways. "type" and "print"
- Xwill print the current message. "top" will only print the first
- XN lines of the current message where N is the value of the
- Xvariable "crt". "next" will go to the next unread message and
- Xprint that. "previous" will go back and read the first unread
- Xmessage previous to the current. "^" will print the first
- Xmessage, "$" will print the last.
- X
- XAny of these commands can be followed by a message list, and
- Xeach message in that list will be printed (or piped to other
- Xcommands).
- X
- XSee also "help msg_list" and the variable $autoprint.
- X%%
- X
- X%alts%
- X alts [hostnames]
- X
- XThe alts command sets a list of hostnames on which you have an
- Xaccount. Normally, when you respond to all recipients of mail,
- Xyour account name will be listed as if you wished to send
- Xyourself mail. If you don't have metoo set, then your name will
- Xbe removed from the mailing list if your login name is on the
- Xlist and the host specified is in the alternates list. The
- Xspecial parameter `*' instructs alts to match all hostnames; in
- Xthat case, only the login name is tested.
- X%%
- X
- X%source%
- X source/saveopts [file]
- X
- XThe source/saveopts commands will load/save all variable
- Xsettings, options, aliases, cmd's, ignored headers ...
- Xeverything you can set, it loads or saves. The file read or
- Xwritten follows these rules:
- X
- X1) If a filename is given, that file is used
- X2) The file described by the environment variable MAILRC
- X3) In the user's home directory: .mushrc (if it exists)
- X4) In the user's home directory: .mailrc (if it exists)
- X
- XIf saveopts is used and the file exists, confirmation will be
- Xrequested before the file is overwritten.
- X%%
- X
- X%help%
- X help [item]
- X
- XType "help" with no arguments for a list of valid items.
- X%%
- X
- X%general%
- XThis is the general help message. To get help on a specific
- Xcommand, try "command -?". Extended help is given by typing
- X"help item" where item is one of:
- X path, msg_list, prompt, hdr_format
- XHelp with msg_list is highly advisable!
- X
- XType "?" to get a list of available commands. Try "? command"
- Xto get help on the particular command that you specify.
- X
- XUse "set ?variable" to get help with specific variables.
- X%%
- X
- X%path%
- XWhenever "path" is specified, the following syntax is legal
- Xbesides 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%%
- X
- X%msg_list%
- XA "msg_list" references one or more messages. The user
- Xspecifies 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
- XIn the last case, N and M may be * ^ $ . or digits referencing
- Xexplicit message numbers. The range must be in ascending order.
- X
- XYou can also negate messages by placing the message list inside
- Xbraces, `{' `}' -- thus, the expression "2-19 {11-14}"
- Xreferences messages 2 through 19 except for those from 11
- Xthrough 14.
- X
- XCommands can be "piped" to one another, because the return value
- Xof a command is a msg_list, not text. For example,
- X pick -f fred | lpr
- Xwill find all messages "from fred" and send them to the printer.
- X
- XCommands dealing with more than one message process them in
- Xnumeric order -- not necessarily the order specified. Thus, the
- Xcommand "save 1-5 9 7 6 file" will save the messages in
- Xascending order, not in the order given.
- X%%
- X
- X%hdr_format%
- XThis variable controls the display of message headers. Use:
- X set hdr_format="string"
- Xto change the header display. The string uses printf style
- Xformatting 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 %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
- XA field specifier may be used in any % expansion. Thus, "%20s"
- Xwill print the first 20 characters of the Subject. No matter
- Xwhat the formatting string, the message number, the status of
- Xthe message and a '>' (if this is the "current" message) is
- Xbefore any user defined format is printed.
- X%%
- X
- X%prompt%
- XThis variable controls the prompt that mush will display.
- X set prompt = "string"
- XThe "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 \n newline
- X \t tab
- X%%
- X
- X%preserve%
- X preserve [msg_list]
- X
- XThe "preserve" command marks messages to be saved in your system
- Xmailbox. Unless explicitly preserved, all mail that you read
- Xwill be saved in ~/mbox (or the file specified by $mbox). Deleted
- Xmessages are preserved only if also undeleted (see "delete -?").
- XWhen a message is preserved, the `P' status bit will appear in the
- Xheader summary display for that message.
- X
- XThe "unpreserve" command reverses the effect of "preserve".
- X
- XSetting the boolean variable $hold is equivalent to preserving
- Xeach message as you read it, except that no `P' status is set.
- X%%
- X
- X%save%
- X save/write/copy [-s|-S|-a|-A] [-f] [msg_list] [filename]
- X
- XIf no filename is specified, ~/mbox (or the value of the
- Xvariable "mbox") is used. Save and write will append msg if
- X`file' already exists. Specifying -f will overwrite the
- Xfile (e.g., erasing it first).
- X
- XTo save messages to a filename beginning with a digit, escape
- Xthe filename with a backslash (\).
- X
- XThe "write" command will write message without the headers (msg
- Xbody only). Save and write both mark messages for deletion
- Xunless $keepsave is set. The "copy" command is identical to
- X"save" except that messages are not marked for deletion
- X(identical to having the variable "keepsave" set).
- X
- XThe -s and -S options save messages to files named by the
- Xsubject of the message. If more than one message is specified,
- Xthen the message subject of each message is used. If -S is
- Xspecified, then the subject of the first message is used for all
- Xmessages. Spaces and forward slashes (/) are converted to
- Xunderscores (_).
- X
- XThe -a and -A options save messages by author's login name.
- X%%
- X
- X%lpr%
- X lpr [-n] [-h] [msg_list]
- X
- XSend 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
- XThe variable $printer can be used to specify a default printer;
- Xfor example, "set printer=lp" is the same as always using "-Plp".
- XThe variable $print_cmd can be used to specify a program other
- Xthan "lpr" to use for printing.
- X
- XSee also the variable $alwaysignore.
- X%%
- X
- X%mail%
- X mail [mail-flags] [recipients]
- X
- XCompose 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
- XThe -f option will add new headers and automatically send the
- Xindicated messages to the list of recipients unless -E or -e
- Xis also given. The -I and -i options will read the indicated
- Xmessages into the text of your letter, surrounded by the text
- Xof variables pre_indent_str, indent_str, and post_indent_str.
- X
- XThe -h option reads a draft file, which should already include
- Xmessage headers. The -H option reads a text file, which should
- XNOT include headers. If the -U option is also given, the draft
- Xis sent immediately.
- X
- XSee also the variables $ask, $askcc, $autoedit, $autoinclude,
- X$autosign, $autosign2, $dot, $edit_hdrs, $escape, $fortune,
- X$fortunates, $logfile, $record, $no_expand, $no_hdrs, $realname,
- X$sendmail, $verbose, $verify, and $wrapcolumn.
- X%%
- X
- X%respond%
- X replysender/replyall [msg-list] [-r path] [mail-flags] [recipients]
- X
- XThe "replysender" command replies only to the sender of a
- Xmessage, whereas "replyall" responds to everyone on the To: and
- XCc: lines of the message.
- X
- XThe command "reply" is identical to "replysender".
- X
- XIf a message list is indicated, then each message on the list is
- Xreplied to in the same manner. If -r is specified with a host or
- Xpath (uucp-style), then each address in the list is routed via
- Xthis path. This overrides the value of auto_route (see man page).
- X
- XThe address of the author is obtained from certain headers in
- Xhis message to you. Unless you specify otherwise, mush will
- Xsearch for the headers Reply-To: Return-Path: and From:. You
- Xcan override these values by setting the variable reply_to_hdr.
- X
- X set reply_to_hdr = "sender reply-to return-path from_"
- X
- XThis example shows that mush will search for (in order), the
- Xheaders listed in the reply_to_hdr variable. If one header isn't
- Xfound, then mush looks for the next in the list. If none of the
- Xheaders in the list are found, the default headers (mentioned
- Xabove) are searched. The last header listed in the example is
- Xthe special "From " header. See the man page for more details.
- X
- XType "mail -?" for information on legal mail flags.
- X
- XSee also the variables $auto_route, $domain_route, $in_reply_to,
- X$known_hosts, $metoo, $reply_to_hdr, and those listed by "mail -?".
- X%%
- X
- 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)
- X -R by subject including Re: (alphabetical)
- X -s by subject ignoring Re: (alphabetical)
- X -S by status
- X
- XAny combination of the options can be given. Each comparison
- Xproceeds from left to right through the list of criteria,
- Xstopping when an ordering has been determined or no criteria
- Xremain. The optional -r flag will reverse the order of the
- Xnext comparison specified. Example:
- X
- X sort -i -a -r -d
- X
- XThe above will sort by author first, ignoring case, and will
- Xsort by reverse date (most recent first) for each author. The
- X-r option can be given once for each criterion and applies
- Xonly to the first criterion that follows it. Giving -r twice
- Xin succession (-r -r) does NOT negate the reversal! Whatever
- Xoption follows the rightmost -r will have its sense reversed.
- X
- XUnlike -r, the -i option is recognized at most once and applies
- Xto all alphabetical sorts in the list of criteria.
- X
- XBy default (no parameters), sort orders messages by status:
- XNew, unread messages are first, followed by preserved messages
- Xand finally the deleted messages are placed at the end. If -r
- Xis the only flag given, the status order is reversed.
- X
- XIf the $date_received variable is set, sorting by date is
- Xdone using the date you received the message. Otherwise,
- Xmessages are sorted by date sent by the original author.
- X
- XSee also the variable $sort.
- X%%
- X
- 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]] [[-e] <pat>]
- X
- XSearch for patterns within messages. Entire messages are
- Xsearched for <pattern> unless -f, -h, -s, or -t is specified.
- XOnly one of -d, -f, -h, -s, -t and -ago can be specified; no
- Xpattern is used with -d and -ago; and -x may not be used in
- Xconjunction 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
- XExamples:
- 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
- XA description of the pick operation will be printed before the search
- Xis performed, unless the value of the variable $quiet contains the
- Xfield "pick", or pick is piped to another mush command.
- X%%
- X
- X%alias%
- X alias [name [namelist]]
- X
- XOptions 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
- XA "namelist" consists of one or more addresses. An address may
- Xbe a name already set to another list, a valid user, a file or
- Xa program. Filenames must be full pathnames, i.e., they must
- Xbegin with a '/' (or with a ~, which expands to some home dir).
- XA "program" must start with a pipe symbol and be encased in
- Xquotes:
- X
- X "|program_name"
- X
- XThe command "expand" will print addresses (including sublists)
- Xassociated with the given alias.
- X
- XSee also the variable $no_expand.
- X%%
- X
- X%from%
- X from [+|-] [msg-list]
- X
- XWith no parameters, "from" will print the current message's
- Xheader line. If given a message list, "from" will print the
- Xheaders of the listed messages.
- X
- XThe special parameters `-' and `+' can be given to move the
- Xcurrent message pointer to the previous or next message
- Xrespectively, while also printing that message's header.
- X
- XIf a message list was given in addition to `-' or `+', then
- Xthe current message pointer will be set to the first or last
- Xmessage, respectively, in the message list given.
- X
- XExamples:
- X
- X from - 10-30 {16}
- Xwill print the headers of messages 10 through 30 except for
- Xmessage 16 and set the current message pointer to 10.
- X
- X pick -f Dan | from +
- Xwill print the headers of all messages that contain "Dan" in the
- Xauthor's name and set the current message pointer to the last
- Xone of that kind in the list.
- X
- X from +
- Xwill print the header of the message after the current message
- Xand increment the current message pointer to that message.
- X
- XSee also the "headers" command and "help hdr_format".
- X%%
- X
- X%my_hdr%
- X my_hdr [header[: string]]
- X
- XThis command is used to set, unset or view your personalized
- Xmessage headers. These headers are included in all your
- Xoutgoing mail.
- X
- XOptions 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
- XNote that there is no space between the header name and the
- Xcolon in the third form of the command.
- X%%
- X
- X%fkey%
- X fkey [<sequence> [command]]
- X unfkey <sequence>
- X
- XThis command is used to make function key settings in Suntools
- X(graphics) mode. When run as a tool (-t on command line),
- Xchoose the Options item, and the "function key" menu option.
- X
- XThe unfkey command removes the setting for a given string.
- X%%
- X
- X%cmd%
- X cmd [name [value]]
- X
- XThis function is used to establish command aliases; cmd's are
- Xjust 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
- XThe value must be quoted if it is to contain command separators
- Xsuch as `;' or `|'.
- X
- XIf you want to reference history commands within a cmd,
- Xescape the ! with a backslash. For example:
- X
- X cmd r 'replysender \!* ; delete -t'
- X
- Xwill cmd "r" to reply using whatever parameters you have given on
- Xthe command line and then delete that message and print the next
- Xmessage (-t parameter to "delete").
- X%%
- X
- 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 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
- XThe "headers" command prints out a screenful of headers.
- XDeleted messages are not normally shown; set "show_deleted" to
- Xinclude deleted messages.
- X
- XThe command ":c" is equivalent to "headers -H:c". The -H can be
- Xomitted, i.e., "headers :c" will also work.
- X
- XSee also "help hdr_format".
- X%%
- X
- 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
- XThe "folder" command changes the current folder; with no parameters,
- Xit prints the name of the current folder. For compatibility with
- Xolder versions, the single character `!' is equivalent to -n.
- X
- X"Folder" treats the characters `+' and `~' as metacharacters when
- Xthey are the first character of a file name. `~' is expanded to the
- Xname of the user's home directory, or to another user's home if it
- Xis given as "~username" (no `/' between the `~' and the name). `+'
- Xis expanded to the user's folder directory ("~/Mail" or the value of
- X$folder); no `/' is required between `+' and the file name, so both
- X"+file" and "+/file" refer to the same file.
- X
- XThe "update" command updates the current folder. In this case, only
- Xthe -N and -r options are recognized; "update -r" changes the current
- Xfolder to read only mode AFTER updating it.
- X
- XSee also the variable $folder.
- X%%
- X
- X%quit%
- X quit/exit
- X
- XThese commands end a mush session. "quit" will update your
- Xmailbox; if new mail has come in, you will be told so and given
- Xan option whether to really quit or not. "exit" will leave mush
- Xneither updating your mailbox nor checking for new mail.
- X%%
- X
- X%ls%
- X ls [options]
- X
- XThe "ls" command is exactly like the UNIX command "ls". All
- Xparameters are the same. The "folders" command is equivalent
- Xto doing "ls -FR $folder" from the Mush prompt.
- X%%
- X
- X%shell%
- X sh [command]
- X
- XIf a "command" is given, that UNIX command will be executed
- Xunder the Bourne shell. If no command is specified, then an
- Xinteractive shell will be started. The environment variable
- XSHELL or the local mail shell variable $shell describes the
- Xshell to invoke. If none is set, then the default shell is
- Xdefined by the system administrator (currently set to csh).
- X
- XUsers on systems with job control will probably have little
- Xuse for the sh command.
- X%%
- X
- X%stop%
- X stop
- X
- XThe stop command sends a stop signal to the mail shell. It is
- Xequivalent to your tty job-control stop character (often ^Z).
- XSince the mush shell never needs to be exited, the command 'q'
- Xmay be "cmd"ed to "stop;await" and csh users may have
- X alias mail %mush
- Xto bring mush into the foreground rather than having to invoke
- Xit again. New mail will be read into the shell automatically
- Xand much time and energy is saved.
- X%%
- X
- X%curses%
- X curses
- X
- XThe curses-based interface for Mush does not require a graphics
- Xdisplay, but does requires a terminal which can handle upline
- Xcursor movement capabilities. All commands are one or two
- Xkeystroke commands and are executed as soon as the key is typed.
- X
- XFor a list of current key-to-command bindings, use the "bind"
- Xcommand (defaults to 'b' in curses mode).
- X
- XSee also the variable $curses_help.
- X%%
- X
- X%bind%
- X bind [<sequence> <curses-command> [<parameters>]]
- X unbind <sequence>
- X
- XBinding is done for the curses interface only. It allows the
- Xuser to bind keystrokes or key sequences to curses-interface
- Xcommands. You cannot bind keystrokes to regular mush commands
- Xusing bind.
- X
- XA bound key-sequence (input by the user) will be converted into
- Xthe curses command it is bound to. For a list of all curses
- Xcommands, issue the "bind" command and follow the instructions
- Xto get a list. Currently, parameters are ignored for all curses
- Xcommands except the special command "macro".
- X
- XWhen specifying sequences, you may enter almost anything at the
- Xkeyboard that you want to type. This includes most control
- Xcharacters. A special syntax is provided to specify control
- Xcharacters if you wish to set up default key bindings in your
- Xinitialization file without using real control characters.
- X
- XTo bind keystrokes that are control characters in the
- Xinitialization file, you must use the notation "\CX" where "X"
- Xis an upper-case letter representing the control key you want to
- Xuse. "\CN" would be control-N; "\n" is carriage return. You may
- Xnot bind keyboard generated signals; for most users, those key
- Xsequences are control-C and control-\. For users with job
- Xcontrol, the suspend characters (usually control-Z and
- Xcontrol-Y) are also ignored.
- X
- XTo specify the escape key, use "\E"; "\C[" will not work.
- X
- XTrying to bind a key sequence which prefixes another sequence is
- Xan error and the user is warned that the longer binding will not
- Xwork. The binding will take place, however, because it is
- Xpossible to unbind the shorter sequence, thus validating the
- Xlonger sequence.
- X
- XThe special curses command "macro" allows a string to be
- Xexecuted just as if the user typed it directly. Issue the
- X"bind-macro" command for more details.
- X
- XBindings are removed with the "unbind" command.
- X%%
- X
- X%msg_flags%
- X flags [[+|-] [flag-bits]] [msg-list]
- X
- XAny 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
- XThis command displays the status of messages by default.
- XIf a msg-list is specified, it will tell which bits of the
- Xmessage are set. If any (one or more) of the bits are
- Xgiven and no + or - modifier is specified, then the status
- Xof each message in the list will be set to that status
- Xabsolutely (other status flags are lost). However, if a +
- Xor - is specified, then the status is modified for that bit
- Xto on (+) or off (-).
- X
- XIf no list is given, then the list of messages is taken
- Xfrom a pipe (if piped) or the current message is used.
- X%%
- X
- X%setenv%
- X setenv VARIABLE [value]
- X
- XVariable names may be any string, but traditionally environment
- Xvariables are all upper case. If no "value" is specified, then
- Xthe variable name will be set to an empty string. If the value
- Xcontains spaces, you should enclose the string in quotation
- Xmarks. Use printenv to print a list of all your environment
- Xvariables.
- X%%
- X
- X%unsetenv%
- X unsetenv VARIABLE
- X
- XYou must specify one and only one variable to unset in your
- Xenvironment variable settings. Use printenv to print a list of
- Xall your environment variables.
- X%%
- X
- X%printenv%
- X printenv [VARIABLE]
- X
- XDisplay the entire current environment, or the value of the
- Xspecified environment variable.
- X
- XAlso see "setenv" and "unsetenv".
- X%%
- X
- X%edit_msg%
- X edit [msg_list]
- X
- XThe "edit" command lets you edit messages in your folder. The
- Xeditor used is determined by the variable $editor, the environment
- Xvariable EDITOR, the variable $visual and the environment variable
- XVISUAL in that order. If none of those variables are set, the
- Xdefault visual editor will be used. The "v" command is the same
- Xas "edit" but will test only $visual and VISUAL.
- X
- XWhen editing messages, be careful not to remove certain message
- Xheaders such as Date:, From:, or any others that look important.
- XIf you remove or change something you shouldn't have, you will
- Xbe notified and the temporary file used to edit the message will
- Xnot be removed.
- X%%
- X
- X%bind-macro%
- X bind-macro [<sequence> [<expansion>]]
- X
- XThe "bind-macro" command allows you to set macros in curses
- Xmode, so that one keystroke (or a few) will act as though you
- Xhad typed a longer sequence. Using "bind-macro" is equivalent
- Xto specifying the "macro" special command as a parameter to
- Xthe "bind" command.
- X
- XGiven no parameters, "bind-macro" will list all current curses
- Xmode macros. Given only a <sequence>, it will show the current
- Xbinding for that sequence. Given both a <sequence> and an
- X<expansion>, it will create a macro such that, when the
- X<sequence> is typed in curses mode, the effect will be the same
- Xas if the <expansion> had been typed instead.
- X
- XThe same format for control characters that is used for the
- X"bind" command may be used in both the <sequence> and the
- X<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
- XExample:
- X bind-macro F [folder]+record\n
- X
- XIf you are in curses mode and hit the F key, then the curses
- Xmode command "folder" will execute and +record (followed by
- Xa carriage return) will be entered as if you typed it.
- X
- XMacros are removed with the "unbind" command, see "bind -?".
- X
- XAlso see the "map" and "map!" commands.
- X%%
- X
- X%map%
- X map [<sequence> [<expansion>]]
- X unmap <sequence>
- X
- XThe "map" command allows you to use one keystroke (or a few) and
- Xhave it act as though you had typed a longer sequence.
- X
- XGiven no parameters, "map" will list all current line mode
- Xmacros. Given only a <sequence>, it will show the current
- Xbinding for that sequence. Given both a <sequence> and an
- X<expansion>, it will create a macro such that, when the
- X<sequence> is typed in line mode, the effect will be the same
- Xas if the <expansion> had been typed instead.
- X
- XThe same format for control characters that is used for the
- X"bind" command may be used in both the <sequence> and the
- X<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
- XExample:
- X map & print\n
- X
- XIf you are not in curses mode and hit the & key, then it will
- Xbe as if you typed the word "print" and hit carriage return.
- X
- XTo type a character without having the mapping expanded, precede
- Xthe character with a backslash (\).
- X
- XMappings are removed with the "unmap" command.
- X
- XAlso see the "map!" and "bind" commands.
- X%%
- X
- X%map!%
- X map! [<sequence> [<expansion>]]
- X unmap! <sequence>
- X
- XThe "map!" command allows you to set macros in message
- Xcomposition mode, so that one keystroke (or a few) will act
- Xas though you had typed a longer sequence. map!'s take
- Xeffect regardless of whether you started the letter from
- Xcurses mode or line mode.
- X
- XGiven no parameters, "map!" will list all composition mode
- Xmacros. Given only a <sequence>, it will show the current
- Xbinding for that sequence. Given both a <sequence> and an
- X<expansion>, it will create a macro such that, when the
- X<sequence> is typed in message composition mode, the effect will
- Xbe the same as if the <expansion> had been typed instead.
- X
- XThe same format for control characters that is used for the
- X"bind" command may be used in both the <sequence> and the
- X<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
- XExample:
- X map! ! <BANG>
- X
- XIf you are typing in a letter regardless of which interface you
- Xuse and you hit the ! key, then it would be as if you typed the
- Xkeys "<BANG>".
- X
- XTo type a character without having the mapping expanded, precede
- Xthe character with a backslash (\).
- X
- XMappings are removed with the "unmap!" command.
- X
- XAlso see the "bind" and "map" commands.
- X%%
- X
- X%eval%
- X eval [-h|-p] args ...
- X
- XThis command causes its arguments to be re-parsed and then
- Xexecuted as a mush command. Example:
- X
- X set initprompt='"$hostname:$cwd "'
- X eval set prompt=$initprompt
- X
- XIf the -h flag is given, then eval looks for formatting parameters
- Xas defined for the variable $hdr_format, and expands the formats
- Xfor the "current" message before executing the command. Example:
- X
- X eval -h pick -f %f
- X
- Xwill find all messages from the same author as the current message.
- X
- XIf the -p flag is given, then eval expands formatting parameters as
- Xas defined for the variable $prompt. The -h and -p flags may not be
- Xused together in the same eval.
- X%%
- X
- X%pipe_msg%
- X pipe [-p pattern] [msg-list] [unix-command] [cmd-args]
- X
- XThis command is used to send a message to a unix command. The
- Xcommand will take its input from the message(s) passed to the pipe
- Xcommand. By default, the entire message (including headers) is
- Xsent. Ignored headers (see "ignore -?" and "set ?show_hdrs") can
- Xbe suppressed by setting the variable $alwaysignore.
- X
- XYou can pipe (|) messages to this command rather than give a
- Xmsg-list, but if no msg-list is given and there is no pipe, the
- Xcurrent message is used. The unix-command is executed via "sh",
- Xso csh aliases may not be used.
- X
- XIf invoked with a capital letter (Pipe), only the bodies of the
- Xmessages will be fed to the unix-command -- all headers will be
- Xomitted.
- X
- XA pattern can be specified to indicate which line should start
- Xthe lines that are sent to the unix command. The pattern must
- Xmatch literally (no regular-expressions) at the beginning of a
- Xline. Once the pattern is found, that line and all succeeding
- Xlines are sent to the unix command.
- X
- XIf the unix-command is omitted, then /bin/sh is used and the
- Xpattern searched for is "#!". Therefore, "pipe" with no arguments
- Xcan be used to treat a message as a shell script.
- X
- XExamples:
- 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%%
- X
- X%merge%
- X merge [-N] folder-name
- X
- XThe contents of the specified folder are read into the current
- Xfolder. If -N is not specified, a header summary is printed
- Xfor each message read (see "headers -?").
- X
- XA list of all the merged messages is returned for use in pipes.
- X%%
- X
- X%echo%
- X echo [-n] [-h | -p] args
- X
- XEcho simply echoes the parameters to the command back to the user.
- X
- XIf the -n flag is given, then no newline is appended.
- XIf the -h flag is given, then echo looks for formatting parameters
- Xas if the "from" command were given on the "current" message.
- XIf the -p flag is given, then echo looks for formatting parameters
- Xas if your prompt were changed temporarily.
- X
- XExamples:
- X echo -h This message is from %a and is dated %d
- Xmight 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.
- Xmight produce:
- X There are 5 new messages to read in /usr/spool/mail/argv.
- X
- XNote that -h and -p cannot be specified together.
- X%%
- X
- X%undigest%
- X undigest [-m] [-p pattern] [msg_list] [filename]
- X
- XA "digest" is a mail message which is a collection of other mail messages
- Xmailed to a "moderator" by other users. The moderator compiles all the
- Xmessages into a folder and sends the result to all the subscribers of the
- Xmailing list. The undigest command disassembles the entries into the set
- Xof messages which comprises the digest.
- X
- XThe -m option will merge these messages into the current folder. Otherwise,
- Xif a filename is specified, a new folder is created and the user can change
- Xfolders to read the messages separately.
- X
- XThe -p option specifies an alternate pattern to use as the digest article
- Xseparator. The pattern must match literally at the beginning of a line.
- XThe default pattern is "--------" (eight hyphens).
- X
- XIf a message list is specified, each digest is disassembled to the same
- Xfilename (if given). If no filename is given and the user did not request
- Xa merge, then a folder is created based on the subject of the digest.
- X%%
- X
- X%await%
- X await [-T delay]
- X
- XInstructs the shell to wait for new mail to arrive. New mail is checked
- Xevery 30 seconds by default; a different delay can be specified by using
- Xthe -T option.
- X
- XIf this command is used in a pipe, its output is its input plus the list
- Xof new messages that have arrived. For example, to show the headers of
- Xall new messages, and set the current message to the first new message:
- X
- X await | from -
- X
- XThe await command terminates only when new mail arrives or a keyboard
- Xinterrupt is generated.
- X%%
- X
- X%cd%
- X cd [directory]
- X
- XChange the current working directory to the specified directory,
- Xor to the user's home directory if none was given.
- X
- XIf the variable $cdpath is set to a list of directory names,
- Xand the argument directory is not an absolute path, mush will
- Xsearch the cdpath directories in the order given for the new
- Xdirectory and change to the first one found. NOTE: The current
- Xdirectory "." MUST BE INCLUDED in the cdpath or it will not be
- Xsearched! This differs from csh, which prefers "." be left out.
- X%%
- X
- X%pwd%
- X pwd
- X
- XPrints the current working directory. The variable $cwd also
- Xholds the current working directory unless reset by the user.
- X%%
- X
- X%delete%
- X delete/undelete [msg-list]
- X
- XThe "delete" command marks the listed messages as deleted. If
- Xno message list is given, the current message is deleted.
- X
- XDeleted messages are not shown in the header summary display
- Xexcept in curses mode and when the variable $show_deleted is set.
- XDeleted messages are ignored by the "pipe" command and by the
- Xcommands that display messages (see "print -?"), but most other
- Xcommands include all messages whether deleted or not.
- X
- XDeleted messages are lost forever when the folder is updated (by
- Xthe "update" command, by changing folders without the "!" flag,
- Xor by exiting with "quit"). Messages can be recovered by the
- X"undelete" command at any time BEFORE the folder is updated.
- X
- XSee also the variable $show_deleted.
- X%%
- X
- X%history%
- X history [-h] [-r] [number]
- X
- XDisplay the command history that mush has recorded, as in csh.
- XOption -h suppresses the history numbers, and option -r shows
- Xthe history in reverse order (most recent first). If a number
- Xis given, that many commands of history are displayed.
- X
- XThe number of commands that mush records is controlled by the
- Xvariable $history. If $history is not set, mush will save only
- Xthe previous command (equivalent to history=1).
- X
- XThe basic forms of history reference are (N is a number and
- Xstr 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
- XModifiers (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
- XIt is not currently possible to combine :p with any of the
- Xother modifiers.
- X
- XAlso see the variable $nonobang.
- X%%
- X
- X%folders%
- X folders
- X
- XList the files in the directory described by the variable $folder.
- XThese files are assumed to be folders of mail messages that can
- Xbe read in by the "folder" command (see "folder -?").
- X
- XAlso see the "ls" command.
- X%%
- X
- X%stty%
- X stty [options]
- X
- XThe "stty" command is equivalent to the UNIX command "stty". All
- Xoptions are the same. Some settings will be temporarily changed
- Xwhile mush is running, but will be restored when mush exits.
- X%%
- END_OF_FILE
- if test 39046 -ne `wc -c <'mush/cmd_help'`; then
- echo shar: \"'mush/cmd_help'\" unpacked with wrong size!
- fi
- # end of 'mush/cmd_help'
- fi
- if test -f 'mush/init.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'mush/init.c'\"
- else
- echo shar: Extracting \"'mush/init.c'\" \(13422 characters\)
- sed "s/^X//" >'mush/init.c' <<'END_OF_FILE'
- X/* init.c (c) copyright 1986 (Dan Heller) */
- X
- X/* init.c -- functions and whatnot that initialize everything */
- X#include "mush.h"
- X#include <pwd.h>
- X
- X#ifdef BSD
- X#include <netdb.h>
- X#endif /* BSD */
- X
- X#ifdef SYSV
- X#include <sys/utsname.h>
- X#endif /* SYSV */
- X
- Xvoid
- Xinit()
- X{
- X char *home, *realname, *argv[4];
- X extern char *getlogin();
- X char buf[MAXPATHLEN];
- X#ifdef SYSV
- X extern struct passwd *getpwuid(); /* sys-v forgot this in pwd.h! */
- X struct utsname ourhost;
- X#else
- X char ourhost[128];
- X#endif /* SYSV */
- X register char *p;
- X struct passwd *entry;
- X int cnt;
- X#ifdef BSD
- X struct hostent *hp;
- X#endif /* BSD */
- X
- X home = getenv("HOME");
- X if (realname = getenv("NAME")) {
- X (void) strcpy(buf, realname);
- X }
- X argv[1] = "=";
- X argv[3] = NULL;
- X
- X if (!(entry = getpwuid(getuid())))
- X if (p = getlogin())
- X strdup(login, p);
- X else {
- X login = "unknown";
- X print("I don't know you, but that's ok.\n");
- X }
- X else {
- X strdup(login, entry->pw_name);
- X if (!home || !*home)
- X home = entry->pw_dir;
- X if (!realname && (realname = entry->pw_gecos)) {
- X if (p = index(realname, ','))
- X *p = 0;
- X for (p = buf; *realname; realname++)
- X if (*realname == '&')
- X *p++ = upper(*login), p += Strcpy(p, login+1);
- X else
- X *p++ = *realname;
- X *p = 0;
- X }
- X endpwent();
- X }
- X if (!home || !*home || Access(home, W_OK)) {
- X if (home && *home)
- X error(home);
- X else
- X print("No home!? ");
- X print_more("Using \"%s\" as home.\n", ALTERNATE_HOME);
- X } else {
- X argv[0] = "home";
- X argv[2] = home;
- X (void) add_option(&set_options, argv);
- X }
- X if (realname) {
- X /* realname has already been copied to buf */
- X argv[0] = "realname";
- X argv[2] = buf;
- X (void) add_option(&set_options, argv);
- X }
- X crt = 24;
- X screen = 18;
- X wrapcolumn = 0; /* Default is no wrap */
- X escape = DEF_ESCAPE;
- X prompt = DEF_PROMPT;
- X
- X#ifdef BSD
- X (void) gethostname(ourhost, sizeof ourhost);
- X if (!(hp = gethostbyname(ourhost))) {
- X error("gethostbyname: %s", ourhost);
- X if (ourname = (char **)calloc((unsigned)2, sizeof (char *)))
- X strdup(ourname[0], ourhost);
- X } else {
- X int n = 0;
- X cnt = 2; /* 1 for ourhost and 1 for NULL terminator */
- X for (p = hp->h_name; p && *p; p = hp->h_aliases[n++])
- X if (strcmp(ourhost, p)) /* if host name is different */
- X cnt++;
- X if (ourname = (char **)calloc((unsigned)cnt, sizeof (char *))) {
- X ourname[--cnt] = NULL;
- X for (p = hp->h_name; p && *p && n >= 0; p = hp->h_aliases[--n])
- X if (strcmp(ourhost, p)) /* if host name is different */
- X ourname[--cnt] = savestr(p);
- X strdup(ourname[0], ourhost); /* cnt better be 0! */
- X }
- X }
- X#endif /* BSD */
- X#ifdef SYSV
- X if (ourname = (char **)calloc((unsigned)2, sizeof (char *))) {
- X if ((uname (&ourhost) >= 0) && (*ourhost.nodename))
- X ourname[0] = savestr(ourhost.nodename);
- X else {
- X /* Try to use uuname -l to get host's name if uname didn't work */
- X char buff[50];
- X char *p;
- X FILE *F;
- X
- X if (F = popen("exec uuname -l", "r")) {
- X if ((fgets(buff, sizeof buff, F) == buff) &&
- X (p = strchr(buff, '\n'))) {
- X *p = '\0'; /* eliminate newline */
- X ourname[0] = savestr (buff);
- X }
- X (void)pclose(F);
- X }
- X }
- X }
- X#endif /* SYSV */
- X if (ourname && ourname[0]) {
- X for (p = buf, cnt = 0; ourname[cnt]; cnt++) {
- X if (cnt)
- X *p++ = ' ';
- X p += Strcpy(p, ourname[cnt]);
- X }
- X argv[0] = "hostname";
- X argv[2] = buf;
- X (void) add_option(&set_options, argv);
- X }
- X
- X init_bindings();
- X}
- X
- X/*
- X * Source a file, or just the default file. Since sourcing files
- X * means reading possible aliases, don't expand the ! as history
- X * by setting the IGN_BANG flag. Since a command in the sourced file
- X * may call source on another file, this routine may be called from
- X * within itself. Continue to ignore ! chars by setting save_bang (local).
- X *
- X * Try opening the file passed to us. If not given, check for the correct
- X * .rc file which is found in the user's home dir.
- X *
- X * return -1 for filesystem errors, -2 for attempting to read a directory.
- X */
- Xsource(argc, argv)
- Xchar **argv;
- X{
- X register char *p;
- X FILE *fp;
- X char file[MAXPATHLEN];
- X u_long save_bang = ison(glob_flags, IGN_BANG);
- X int line_no = 0;
- X
- X if (argc && *++argv && !strcmp(*argv, "-?"))
- X return help(0, "source", cmd_help);
- X if (argc && *argv)
- X (void) strcpy(file, *argv);
- X else if ((p = getenv("MUSHRC")) && *p || (p = getenv("MAILRC")) && *p)
- X (void) strcpy(file, p);
- X else {
- X char *home = do_set(set_options, "home");
- X if (!home || !*home)
- X home = ALTERNATE_HOME;
- X if (Access(sprintf(file, "%s/%s", home, MAILRC), R_OK)
- X && Access(sprintf(file, "%s/%s", home, ALTERNATE_RC), R_OK))
- X if (argc || argv)
- X (void) strcpy(file, DEFAULT_RC);
- X else
- X return -1;
- X }
- X
- X argc = 0; /* don't ignore ENOENT */
- X p = getpath(file, &argc);
- X /* Try the ALT_DEF_RC if DEFAULT_RC fails */
- X if (argc && !strcmp(file, DEFAULT_RC)) {
- X argc = 0; /* don't ignore ENOENT */
- X (void) strcpy(file, ALT_DEF_RC);
- X p = getpath(file, &argc);
- X }
- X if (argc) {
- X /* Don't print error messages for missing default files */
- X if (strcmp(file, ALT_DEF_RC))
- X if (argc == -1) {
- X print("%s: %s\n", file, p);
- X return -1;
- X } else {
- X print("%s is a directory.\n", file);
- X return -2;
- X }
- X return -1;
- X }
- X if (!(fp = fopen(p, "r"))) {
- X if (errno != ENOENT)
- X error("Can't open %s", p);
- X return -1;
- X }
- X turnon(glob_flags, IGN_BANG); /* ignore ! when reading record files */
- X (void) strcpy(file, p);
- X (void) src_parse(file, fp, 0, 0, &line_no);
- X /* if we entered the routine ignoring !, leave it that way. */
- X if (!save_bang)
- X turnoff(glob_flags, IGN_BANG);
- X /* Sourcing might change things, so abort pipes/macros */
- X return 0 - (in_pipe() || in_macro());
- X}
- X
- X/*
- X * Do the actual file parsing for source(). The first argument should
- X * be the name of the file referenced by the second argument. The third
- X * argument is used for handling nested if_else_endif expressions. The
- X * fourth argument is used to keep track of the recursion depth, and the
- X * last argument keeps track of the line number in the current file.
- X *
- X * This function calls itself recursively. It also calls do_command(),
- X * which may in turn call source() recursively.
- X *
- X * If-then-else nesting algorithm:
- X * On any "if" (whether parsing or not), increment if_else
- X * On true "if" when parsing, evaluate by recursion
- X * On false "if" when parsing, set find_else equal to if_else
- X * On any "if" when not parsing, set find_endif equal to if_else
- X * On "else", invert parsing only when find_else equals if_else
- X * When "if" was false and there is nesting, recur for "else"
- X * Skip nested "if...endif" when find_else or find_endif true
- X * On "endif" or when recursion returns, decrement if_else
- X * On "endif", test both find_endif and find_else against if_else:
- X * when either matches, reset that one;
- X * when the lesser (less nested) matches, resume parsing
- X * On "endif", when if_else hits 0, continue (depth 0) or return
- X */
- Xsrc_parse(file, fp, if_else, depth, line_no)
- Xchar *file;
- XFILE *fp;
- Xint if_else, depth, *line_no;
- X{
- X register char *p, *p2, **newargv;
- X static int exited;
- X int parsing = 1, cont_line = 0;
- X int find_else = 0, find_endif = 0;
- X char line[BUFSIZ];
- X int argc;
- X
- X exited = 0;
- X
- X while (p = fgets(&line[cont_line], BUFSIZ - cont_line, fp)) {
- X (*line_no)++;
- X if (*(p2 = no_newln(p)) == '\\') {
- X *p2++ = ' ';
- X cont_line = p2 - line;
- X continue;
- X } else
- X cont_line = 0;
- X /* don't consider comments (#) in lines. check if # is within quotes */
- X if (p = any(line, "\"'#\\")) {
- X register int balanced = 1;
- X do {
- X if (*p == '\\' && p[1])
- X p = any(p+2, "\"'#\\");
- X else if (*p != '#') {
- X /* first find matching quote */
- X register char *quote = index(p+1, *p);
- X if (!quote) {
- X print("%s: line %d: unbalanced %c.\n",
- X file, *line_no, *p);
- X balanced = 0;
- X } else
- X p = any(quote+1, "\"'#\\");
- X }
- X } while (p && *p != '#' && balanced);
- X if (!balanced)
- X continue;
- X if (p && *p == '#')
- X *p = 0; /* found a Comment: null terminate line at comment */
- X }
- X if (!*line || !parsing && !(newargv = mk_argv(line, &argc, 0))
- X || parsing && !(newargv = make_command(line, TRPL_NULL, &argc))) {
- X if (!strncmp(line, "if", 2))
- X find_else = ++if_else, parsing = FALSE;
- X continue;
- X }
- X if (!strcmp(newargv[0], "endif")) {
- X if (!if_else)
- X print("%s: line %d: endif with no \"if\".\n", file, *line_no);
- X else {
- X /* If looking for an else or endif, reset parsing */
- X if (find_endif && find_endif == if_else) {
- X if (find_endif <= find_else || !find_else)
- X parsing = 1, find_else = 0;
- X find_endif = 0;
- X }
- X /* Note: find_else never < find_endif */
- X if (find_else && find_else == if_else)
- X parsing = !parsing, find_else = 0;
- X /* Decrement if_else and check depth */
- X if (--if_else == 0)
- X /* Resume parsing if at the top */
- X if (depth == 0)
- X parsing = 1;
- X /* Return if not at the top */
- X else
- X return 1;
- X }
- X goto bad;
- X } else if (!strcmp(newargv[0], "else")) {
- X if (!if_else)
- X print("%s: line %d: if-less \"else\".\n", file, *line_no);
- X /* If inside an else, ignore nested else;
- X * otherwise, recur when if_else > 1 */
- X else if (!find_else && !find_endif && !parsing) {
- X parsing = src_parse(file, fp, 1, depth + 1, line_no);
- X --if_else;
- X } else if (find_else == if_else || if_else == 1) {
- X find_else = 0;
- X parsing = !parsing;
- X if (!parsing)
- X find_endif = if_else;
- X }
- X goto bad;
- X } else if (!strcmp(newargv[0], "if")) {
- X /* if statements are of the form:
- X * if expr
- X * if !expr or if ! expr
- X * if expr == expr or if expr != expr
- X */
- X int equals = TRUE, pattern = FALSE;
- X register char *lhs = newargv[1], *rhs = NULL;
- X
- X if_else++;
- X /* If parsing, set parsing to 0 until
- X * evaluating the "if" proves otherwise.
- X * If not parsing, skip to the "endif".
- X */
- X if (parsing)
- X parsing = 0;
- X else {
- X if (!find_endif)
- X find_endif = if_else;
- X goto bad;
- X }
- X if (!lhs || !*lhs) {
- X print("%s: line %d: if what?\n", file, *line_no);
- X goto bad;
- X }
- X /* "lhs" is the left hand side of the equation
- X * In this instance, we're doing case 2 above (check for negation).
- X */
- X if (*lhs == '!') {
- X if (!*++lhs && !(lhs = newargv[2])) {
- X print("%s: line %d: syntax error: \"if ! <what?>\"\n",
- X file, *line_no);
- X goto bad;
- X }
- X equals = FALSE;
- X }
- X if (*lhs == '-' && (lhs[1] == 'e' || lhs[1] == 'z') && !lhs[2]) {
- X char *path;
- X int n = 1; /* ignore ENOENT, I'll handle it here */
- X struct stat statb;
- X
- X /* check for existence or zero-length folders/files */
- X if (argc > 3 + (!equals)) {
- X print("%s: line %d: if %s \"filename\"\n",
- X file, *line_no, lhs);
- X goto bad;
- X }
- X path = getpath(newargv[argc-1], &n);
- X parsing = !equals ^ (n == -1 || n == 1 && lhs[1] == 'e' ||
- X !stat(path, &statb) && (lhs[1] == 'e' || !statb.st_size));
- X } else {
- X if (equals && argc > 2) {
- X if (argc != 4) {
- X print("%s: %d: argument count error: %d args.\n",
- X file, *line_no, argc);
- X goto bad;
- X }
- X /* now check newargv[2] for == or != or =~ or !~ */
- X if (!strcmp(newargv[2], "!=") ||
- X (pattern = !strcmp(newargv[2], "!~")))
- X equals = !equals;
- X else if (!strcmp(newargv[2], "=~"))
- X pattern = TRUE;
- X else if (strcmp(newargv[2], "==")) {
- X print("%s: %d: use `==' or `!=' only.\n",
- X file, *line_no);
- X goto bad;
- X }
- X rhs = newargv[3];
- X }
- X if (rhs) {
- X /* Some fun tricks with booleans here.
- X * Extra ! ops make sure all == are on 0 or 1;
- X * aside from that, we want (glob == equals)
- X * or (!strcmp == equals). Make sense?
- X */
- X if (pattern && !glob(lhs,rhs) == !equals)
- X parsing = 1;
- X else if (!pattern && !strcmp(lhs, rhs) == !!equals)
- X parsing = 1;
- X } else if (isdigit(*lhs))
- X parsing = !!(atoi(lhs) ? equals : !equals);
- X else if (!strcmp(lhs, "redirect") && (!isatty(0) != !equals)
- X /* (ison(glob_flags, REDIRECT) && equals ||
- X isoff(glob_flags, REDIRECT) && !equals) */
- X || !strcmp(lhs, "is_shell") && (!is_shell == !equals)
- X || !strcmp(lhs, "is_sending") &&
- X (ison(glob_flags, IS_SENDING) && equals ||
- X isoff(glob_flags, IS_SENDING) && !equals)
- X || !strcmp(lhs, "hdrs_only") &&
- X (hdrs_only && equals || !hdrs_only && !equals)
- X || !strcmp(lhs, "istool") &&
- X (istool && equals || !istool && !equals)
- X || !strcmp(lhs, "iscurses") &&
- X ((iscurses || ison(glob_flags, PRE_CURSES)) && equals
- X || (isoff(glob_flags, PRE_CURSES) &&
- X !iscurses && !equals)))
- X parsing = 1;
- X }
- X if (parsing) {
- X parsing = src_parse(file, fp, 1, depth + 1, line_no);
- X --if_else;
- X }
- X else
- X find_else = if_else; /* Look for a matching else */
- Xbad:
- X free_vec(newargv);
- X continue;
- X }
- X if (parsing && argc > 0)
- X if (!strcmp(newargv[0], "exit")) {
- X if_else = find_else = find_endif = 0;
- X exited = 1;
- X break;
- X } else {
- X (void) do_command(argc, newargv, msg_list);
- X exited = 0;
- X }
- X else
- X free_vec(newargv);
- X }
- X if (if_else && !exited)
- X print("%s: missing endif\n", file);
- X if (depth == 0)
- X (void) fclose(fp);
- X else
- X (void) fseek(fp, 0L, 2); /* Skip ahead to the end */
- X return 0;
- X}
- END_OF_FILE
- if test 13422 -ne `wc -c <'mush/init.c'`; then
- echo shar: \"'mush/init.c'\" unpacked with wrong size!
- fi
- # end of 'mush/init.c'
- fi
- echo shar: End of archive 4 \(of 19\).
- cp /dev/null ark4isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 19 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
-
-