Newsgroups: comp.sources.unix From: ram@acri.fr (Raphael Manfredi) Subject: v26i224: kit - the ultimate mailing kit, Patch19 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 224 Archive-Name: kit/pch19 [The latest patch for kit version 2.0 is #28.] System: kit version 2.0 Patch #: 19 Priority: LOW Subject: forgot the 'range' target in kit's Makefile Subject: unkit will use perl instead of awk, if available Subject: now smart enough to deal with multiple parts from stdin Subject: now recognizes - as being stdin Date: Fri Sep 4 19:28:39 PDT 1992 From: Raphael Manfredi Description: Forgot the 'range' target in the Makefile.SH held in the kit subdirectory. Configure normally automatically extracts the .SH files, but when you want to rebuild the kit subdirectory, it's nice to have range rebuild when it changes... Unkit will use perl instead of awk, if available. This is because awk is really dumb and will not let you open more than 10 or 15 files. If you put more than that amount of kits in a single file, they would not be extracted correctly by awk, but of course perl does not suffer the same limitation. The awk code has been kept, as perl is not a standard yet. Also, kit is now smart enough to deal with multiple parts from stdin, which is really neat when processing multiple kits parts from a mail user agent. For instance, under MH, you can say show 6-10 | unkit to unkit messages 6 through 10. There was a silent limitation which existed before this patch, where the number of parts coming from stdin was limited to 1. As a side effect, unkit now recognizes - as meaing stdin on the command line. That is to say, unkit foo bar - would start unkit'ing messages from the two files foo and bar and then wait for more input on stdin. 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 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: 18 2c2 < #define PATCHLEVEL 18 --- > #define PATCHLEVEL 19 Index: kit/unkit.SH Prereq: 2.0.1.11 *** kit/unkit.SH.old Fri Sep 4 19:28:36 1992 --- kit/unkit.SH Fri Sep 4 19:28:37 1992 *************** *** 19,27 **** # @(#) (c) E. Mogenet April 1990 # @(#) (c) R. Manfredi, 1990 1991 ! # $Id: unkit.SH,v 2.0.1.11 92/08/17 17:59:42 ram Exp $ # # $Log: unkit.SH,v $ # Revision 2.0.1.11 92/08/17 17:59:42 ram # patch18: new -k option, added by Steve Tynor # patch18: do not start unkiting until all parts are here (Jaap Vermulen) --- 19,32 ---- # @(#) (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 + # patch19: now recognizes - as being stdin + # # Revision 2.0.1.11 92/08/17 17:59:42 ram # patch18: new -k option, added by Steve Tynor # patch18: do not start unkiting until all parts are here (Jaap Vermulen) *************** *** 171,186 **** # If no file name is given, process the standard input if test $# -eq 0 then ! eval $unshar_cmd ! else ! # More than one kit part can be held in the files given as argument. ! # Loop over each of the supplied arguments and extract parts based on ! # the leading #!/bin/sh put by the shell archiver. ! ! list='' ! count=0 ! for file in $*; do num=`awk ' BEGIN { a = 0; file = "zag.tmp" } /^#![ ]*\/bin\/sh/ { --- 176,210 ---- # If no file name is given, process the standard input if test $# -eq 0 then ! set X - ! shift ! fi ! # More than one kit part can be held in the files given as argument. ! # Loop over each of the supplied arguments and extract parts based on ! # the leading #!/bin/sh put by the shell archiver. ! ! list='' ! count=0 ! ! for file in $*; do ! # Use perl if possible, as it does not have this stupid awk limitation ! # about the maximum number of opened files. However, I want this to ! # run (barely) even if perl is not available. ! if (perl -v) >/dev/null 2>&1; then ! num=`perl -e ' ! $a = 0; ! open(FILE, ">>zag.tmp"); ! while (<>) { ! if (m|^#!\s*/bin/sh|) { ! $a++; ! open(FILE, ">zag.tmp.$a"); ! } ! print FILE; ! } ! print "$a\n"; ! ' $file` ! else num=`awk ' BEGIN { a = 0; file = "zag.tmp" } /^#![ ]*\/bin\/sh/ { *************** *** 192,247 **** { print >> file } END { printf("%d\n", a) } ' $file` ! name='' ! case "$num" in ! 0) ! rm -f zag.tmp ! echo "unkit: warning: no kit part in $file (skipped)." >&2 ;; ! 1) rm -f zag.tmp.1 echo "unkit: one kit part found in $file." name=$file ;; - *) - echo "unkit: $num kit parts found in $file." >&2 - # Each part is renamed into a zag.xtr.* file to free the name - # space for the next file (each awk extracts into zag.tmp.*). - for part in zag.tmp.*; do - count=`expr $count + 1` - new="zag.xtr.$count" - mv $part $new - name="$name $new" - done - ;; esac ! list="$list $name" ! done ! set X $list ! shift ! case $# in ! 1) ;; *) ! case "$count" in ! 0) ! echo "unkit: found a total of $# kit parts." >&2;; ! *) ! echo "unkit: found $# kit parts ($count parts extracted)." >&2;; esac ;; esac ! # Loop over each identified kir part and unshar it ! for i ! do ! # The command expects "$a" to be the parameter ! eval "a=$i; $unshar_cmd" && ! (test $preserve = no && rm $i) ! done ! # Clean up extracted parts (save disk space before tar extraction) ! rm -f zag.[tx][mt]* ! fi # Now check for file names to find how to decode if test -f z[ace][gbc].ba.aa -a ! -f ark*isdone --- 216,286 ---- { print >> file } END { printf("%d\n", a) } ' $file` ! fi ! name='' ! case "$num" in ! 0) ! case "$file" in ! -) file='stdin';; ! esac ! echo "unkit: warning: no kit part in $file (skipped)." >&2 ! rm -f zag.tmp ! ;; ! 1) ! case "$file" in ! -) ! echo "unkit: one kit part found in stdin." ! name=zag.tmp.1 ;; ! *) rm -f zag.tmp.1 echo "unkit: one kit part found in $file." name=$file ;; esac ! ;; *) ! case "$file" in ! -) file='stdin';; esac + echo "unkit: $num kit parts found in $file." >&2 + + # Each part is renamed into a zag.xtr.* file to free the name + # space for the next file (each awk extracts into zag.tmp.*). + for part in zag.tmp.*; do + count=`expr $count + 1` + new="zag.xtr.$count" + mv $part $new + name="$name $new" + done ;; esac + list="$list $name" + done + set X $list + shift + case $# in + 1) ;; + *) + case "$count" in + 0) + echo "unkit: found a total of $# kit parts." >&2;; + *) + echo "unkit: found $# kit parts ($count parts extracted)." >&2;; + esac + ;; + esac ! # Loop over each identified kit part and unshar it ! for i ! do ! # The command expects "$a" to be the parameter. ! eval "a=$i; $unshar_cmd" && ! (test $preserve = no && rm $i) ! done ! # Clean up extracted parts (save disk space before tar extraction) ! rm -f zag.[tx][mt]* # Now check for file names to find how to decode if test -f z[ace][gbc].ba.aa -a ! -f ark*isdone Index: kit/Makefile.SH Prereq: 2.0.1.5 *** kit/Makefile.SH.old Fri Sep 4 19:28:32 1992 --- kit/Makefile.SH Fri Sep 4 19:28:32 1992 *************** *** 18,26 **** # Makefile for kit (sub-directory kit) # ! # $Id: Makefile.SH,v 2.0.1.5 92/05/02 14:13:13 ram Exp $ # # $Log: Makefile.SH,v $ # Revision 2.0.1.5 92/05/02 14:13:13 ram # patch16: added rules for new range script # --- 18,29 ---- # Makefile for kit (sub-directory kit) # ! # $Id: Makefile.SH,v 2.0.1.6 92/09/04 19:22:28 ram Exp $ # # $Log: Makefile.SH,v $ + # Revision 2.0.1.6 92/09/04 19:22:28 ram + # patch19: forgot the 'range' target + # # Revision 2.0.1.5 92/05/02 14:13:13 ram # patch16: added rules for new range script # *************** *** 67,72 **** --- 70,78 ---- sh $@.SH minikit: minikit.SH + sh $@.SH + + range: range.SH sh $@.SH install: $(scripts) *** End of Patch 19 ***