home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.unix
- From: ram@acri.fr (Raphael Manfredi)
- Subject: v26i223: kit - the ultimate mailing kit, Patch20
- Sender: unix-sources-moderator@efficacy.home.vix.com
- Approved: WhoAmI@efficacy.home.vix.com
-
- Submitted-By: ram@acri.fr (Raphael Manfredi)
- Posting-Number: Volume 26, Issue 223
- Archive-Name: kit/pch20
-
- [The latest patch for kit version 2.0 is #28.]
-
- System: kit version 2.0
- Patch #: 20
- Priority: HIGH
- Subject: added getopt-style option parsing
- Date: Sun Nov 1 15:08:30 PST 1992
- From: Raphael Manfredi <ram@eiffel.com>
-
- Description:
- Added getopt-style option parsing for kit, mailkit and unkit. This
- makes it possible to specify an argument for an option directly
- after the option letter, or specify more than one argument-free
- option, as in -cdv (instead of -c -d -v) or -afoo (for -a foo).
-
-
- Fix: From rn, say "| patch -p -N -d DIR", where DIR is your kit source
- directory. Outside of rn, say "cd DIR; patch -p -N <thisarticle".
- If you don't have the patch program, apply the following by hand,
- or get patch (version 2.0, latest patchlevel).
-
- After patching:
- Configure -d
- make
-
- If patch indicates that patchlevel is the wrong version, you may need
- to apply one or more previous patches, or the patch may already
- have been applied. See the patchlevel.h file to find out what has or
- has not been applied. In any event, don't continue with the patch.
-
- If you are missing previous patches they can be obtained from me:
-
- Raphael Manfredi <ram@eiffel.com>
-
- If you send a mail message of the following form it will greatly speed
- processing:
-
- Subject: Command
- @SH mailpatch PATH kit 2.0 LIST
- ^ note the c
-
- where PATH is a return path FROM ME TO YOU either in Internet notation,
- or in bang notation from some well-known host, and LIST is the number
- of one or more patches you need, separated by spaces, commas, and/or
- hyphens. Saying 35- says everything from 35 to the end.
-
- To get some more detailed instructions, send me the following mail:
-
- Subject: Command
- @SH mailhelp PATH
-
-
- Index: patchlevel.h
- Prereq: 19
- 2c2
- < #define PATCHLEVEL 19
- ---
- > #define PATCHLEVEL 20
-
- Index: kit/mailkit.SH
- Prereq: 2.0.1.9
- *** kit/mailkit.SH.old Sun Nov 1 15:08:23 1992
- --- kit/mailkit.SH Sun Nov 1 15:08:24 1992
- ***************
- *** 18,26 ****
- # @(#) Mailer for kit files
- # @(#) (c) R. Manfredi, 1990 1991
-
- ! # $Id: mailkit.SH,v 2.0.1.9 92/08/17 17:55:16 ram Exp $
- #
- # $Log: mailkit.SH,v $
- # Revision 2.0.1.9 92/08/17 17:55:16 ram
- # patch18: recipient file was wrongly reported as missing
- # patch18: instruction message now saved in case of error
- --- 18,29 ----
- # @(#) Mailer for kit files
- # @(#) (c) R. Manfredi, 1990 1991
-
- ! # $Id: mailkit.SH,v 2.0.1.10 92/11/01 15:08:10 ram Exp $
- #
- # $Log: mailkit.SH,v $
- + # Revision 2.0.1.10 92/11/01 15:08:10 ram
- + # patch20: added getopt-style option parsing
- + #
- # Revision 2.0.1.9 92/08/17 17:55:16 ram
- # patch18: recipient file was wrongly reported as missing
- # patch18: instruction message now saved in case of error
- ***************
- *** 93,98 ****
- --- 96,110 ----
- unsent='' # Parts which could not be sent
- error='' # True when error occurred
-
- + # Ensure proper MAILER and EDITOR variables. I cannot use the ${MAILER:-def}
- + # construct since some shells do not recognize that (/bin/sh on the DEC 3100).
- + case "$MAILER" in
- + '') MAILER="$mailer";;
- + esac
- + case "$EDITOR" in
- + '') EDITOR="$editor";;
- + esac
- +
- # Old Bourne shells do not have functions
- usage='
- echo "Usage: mailkit [-EFVcefhp] [-n base] [-l file] [-r range]";
- ***************
- *** 111,116 ****
- --- 123,175 ----
- exit 1;
- '
-
- + # Process the command line options
- + set X `for arg in $*; do echo $arg; done | awk '
- + BEGIN {
- + optstr = "EFVcefhpn:l:r:"; # getopt-style specification
- +
- + len = length(optstr);
- + for (i = 1; i <= len; i++) {
- + c = substr(optstr, i, 1);
- + if (i < len) a = substr(optstr, i + 1, 1); else a = "";
- + if (a == ":") {
- + arg[c] = 1;
- + i++;
- + }
- + opt[c] = 1;
- + }
- + }
- + {
- + expect = 0;
- + str = $0;
- + if (substr(str, 1, 1) != "-") {
- + print str;
- + next;
- + }
- + len = length($0);
- + for (i = 2; i <= len; i++) {
- + c = substr(str, i, 1);
- + if (!opt[c]) {
- + print sprintf("-%s", substr(str, i));
- + next;
- + }
- + print sprintf("-%s", c);
- + if (arg[c]) {
- + if (i < len)
- + print substr(str, i + 1);
- + else
- + expect = 1;
- + next;
- + }
- + }
- + }
- + END {
- + if (expect)
- + print "?";
- + }
- + '`
- + shift
- +
- # Argument parsing
- while test $# -gt 0
- do
- ***************
- *** 254,260 ****
- fi
-
- # Call the editor
- ! ${EDITOR:-$editor} $message
-
- # Now remove the 4 lines at the top
- # Do not use tail +5, as this may not exist on every system
- --- 313,319 ----
- fi
-
- # Call the editor
- ! $EDITOR $message
-
- # Now remove the 4 lines at the top
- # Do not use tail +5, as this may not exist on every system
- ***************
- *** 325,331 ****
- fi
- cat $part >> $topmsg
- # Remove part sucessfully sent unless '-p' was used
- ! if ${MAILER:-$mailer} $address < $topmsg; then
- test "$preserve" = no && rm -f $part
- else
- echo "mailkit: could not send $part." >&2
- --- 384,390 ----
- fi
- cat $part >> $topmsg
- # Remove part sucessfully sent unless '-p' was used
- ! if $MAILER $address < $topmsg; then
- test "$preserve" = no && rm -f $part
- else
- echo "mailkit: could not send $part." >&2
- ***************
- *** 355,361 ****
- EOM
- cat >>$topmsg <$message
- echo "Mailing instructions..."
- ! if ${MAILER:-$mailer} $address < $topmsg; then
- rm -f $topmsg
- else
- echo "mailkit: could not send instructions." >&2
- --- 414,420 ----
- EOM
- cat >>$topmsg <$message
- echo "Mailing instructions..."
- ! if $MAILER $address < $topmsg; then
- rm -f $topmsg
- else
- echo "mailkit: could not send instructions." >&2
-
- Index: kit/unkit.SH
- Prereq: 2.0.1.12
- *** kit/unkit.SH.old Sun Nov 1 15:08:28 1992
- --- kit/unkit.SH Sun Nov 1 15:08:29 1992
- ***************
- *** 19,27 ****
- # @(#) (c) E. Mogenet April 1990
- # @(#) (c) R. Manfredi, 1990 1991
-
- ! # $Id: unkit.SH,v 2.0.1.12 92/09/04 19:28:28 ram Exp $
- #
- # $Log: unkit.SH,v $
- # Revision 2.0.1.12 92/09/04 19:28:28 ram
- # patch19: unkit will use perl instead of awk, if available
- # patch19: now smart enough to deal with multiple parts from stdin
- --- 19,30 ----
- # @(#) (c) E. Mogenet April 1990
- # @(#) (c) R. Manfredi, 1990 1991
-
- ! # $Id: unkit.SH,v 2.0.1.13 92/11/01 15:08:15 ram Exp $
- #
- # $Log: unkit.SH,v $
- + # Revision 2.0.1.13 92/11/01 15:08:15 ram
- + # patch20: added getopt-style option parsing
- + #
- # Revision 2.0.1.12 92/09/04 19:28:28 ram
- # patch19: unkit will use perl instead of awk, if available
- # patch19: now smart enough to deal with multiple parts from stdin
- ***************
- *** 127,132 ****
- --- 130,182 ----
- echo " "" -V : print current version and patch-level.";
- exit 1
- '
- +
- + # Process the command line options
- + set X `for arg in $*; do echo $arg; done | awk '
- + BEGIN {
- + optstr = "bhlprVk:"; # getopt-style specification
- +
- + len = length(optstr);
- + for (i = 1; i <= len; i++) {
- + c = substr(optstr, i, 1);
- + if (i < len) a = substr(optstr, i + 1, 1); else a = "";
- + if (a == ":") {
- + arg[c] = 1;
- + i++;
- + }
- + opt[c] = 1;
- + }
- + }
- + {
- + expect = 0;
- + str = $0;
- + if (substr(str, 1, 1) != "-") {
- + print str;
- + next;
- + }
- + len = length($0);
- + for (i = 2; i <= len; i++) {
- + c = substr(str, i, 1);
- + if (!opt[c]) {
- + print sprintf("-%s", substr(str, i));
- + next;
- + }
- + print sprintf("-%s", c);
- + if (arg[c]) {
- + if (i < len)
- + print substr(str, i + 1);
- + else
- + expect = 1;
- + next;
- + }
- + }
- + }
- + END {
- + if (expect)
- + print "?";
- + }
- + '`
- + shift
-
- # Option parsing
- while test $# -gt 0
-
- Index: kit/kit.SH
- Prereq: 2.0.1.10
- *** kit/kit.SH.old Sun Nov 1 15:08:19 1992
- --- kit/kit.SH Sun Nov 1 15:08:20 1992
- ***************
- *** 26,34 ****
- !GROK!THIS!
- $spitshell >>kit <<'!NO!SUBS!'
-
- ! # $Id: kit.SH,v 2.0.1.10 92/05/02 14:13:45 ram Exp $
- #
- # $Log: kit.SH,v $
- # Revision 2.0.1.10 92/05/02 14:13:45 ram
- # patch16: new option -S to set maximum part size
- #
- --- 26,37 ----
- !GROK!THIS!
- $spitshell >>kit <<'!NO!SUBS!'
-
- ! # $Id: kit.SH,v 2.0.1.11 92/11/01 15:08:04 ram Exp $
- #
- # $Log: kit.SH,v $
- + # Revision 2.0.1.11 92/11/01 15:08:04 ram
- + # patch20: added getopt-style option parsing
- + #
- # Revision 2.0.1.10 92/05/02 14:13:45 ram
- # patch16: new option -S to set maximum part size
- #
- ***************
- *** 124,129 ****
- --- 127,179 ----
- echo " "" -x : use Cipher Block Chaining DES encryption (default).";
- exit 1
- '
- +
- + # Process the command line options
- + set X `for arg in $*; do echo $arg; done | awk '
- + BEGIN {
- + optstr = "BEFHMVXefhpxS:a:d:k:l:m:n:s:"; # getopt-style specification
- +
- + len = length(optstr);
- + for (i = 1; i <= len; i++) {
- + c = substr(optstr, i, 1);
- + if (i < len) a = substr(optstr, i + 1, 1); else a = "";
- + if (a == ":") {
- + arg[c] = 1;
- + i++;
- + }
- + opt[c] = 1;
- + }
- + }
- + {
- + expect = 0;
- + str = $0;
- + if (substr(str, 1, 1) != "-") {
- + print str;
- + next;
- + }
- + len = length($0);
- + for (i = 2; i <= len; i++) {
- + c = substr(str, i, 1);
- + if (!opt[c]) {
- + print sprintf("-%s", substr(str, i));
- + next;
- + }
- + print sprintf("-%s", c);
- + if (arg[c]) {
- + if (i < len)
- + print substr(str, i + 1);
- + else
- + expect = 1;
- + next;
- + }
- + }
- + }
- + END {
- + if (expect)
- + print "?";
- + }
- + '`
- + shift
-
- while test $# -gt 0
- do
-
- *** End of Patch 20 ***
-