[net.sources] leading comments

itkin@luke.UUCP (Steven List) (08/16/85)

I'm posting this to net.sources, but it's also applicable to mod.sources
and net.sources.games.  I'll assume that all three are read by the same
group of people.

Most of us, when posting a source file (shell archive or otherwise), 
usually put some nice commentary at the beginning.  Unfortunately, this
means that the file must be (1) saved to a file, (2) edited to remove
the commentary, and (3) processed by the shell.

I'd like to suggest that when we put some commentary at the beginning,
each line be preceded by the shell comment character (#).  This would
allow the file to be saved (at least from rn with `w') without the
header information and processed immediately by the shell.  For those
who don't want to save the source, this allows piping directly to the
shell (again, rn's `w').

Small savings, but nice.  Don't you think?
-- 
***
*  Steven List @ Benetics Corporation, Mt. View, CA
*  Just part of the stock at "Uncle Bene's Farm"
*  {cdp,greipa,idi,oliveb,sun,tolerant}!bene!luke!itkin
***

keith@gargoyle.UUCP (Keith Waclena) (08/19/85)

In article <318@luke.UUCP> itkin@luke.UUCP (Steven List) writes:
>[...] 
>Most of us, when posting a source file (shell archive or otherwise), 
>usually put some nice commentary at the beginning. [...]
>
>I'd like to suggest that when we put some commentary at the beginning,
>each line be preceded by the shell comment character (#).  This would
>allow the file to be saved (at least from rn with `w') without the
>header information and processed immediately by the shell.
>[...]


The unshar program (previously posted to net.sources, I think) strips
leading commentary in a very clever way; it strips text up to a line
containing the words ``cut'' and ``here'' in that order and then runs
the rest of the file through sh. In rn you can say ``w|unshar'' to
get the results you want.

Unshar is a good companion to shar; if you can't find it locally,
send me mail and I'll see if we still have the sources here.

Now a quick question: (our) rn always prepends a line like ``Article
whatever from net.random'' whether I save via s or w. This screws our
mail program; if I say ``use mbox format'' mail won't recognize the
file as such unless I edit out that offending line.. can anyone tell
me how to get rn to leave out that line?

Thanks.
-- 

----------------------------------------------------------------------------
Keith Waclena                          uucp:     ..!ihnp4!gargoyle!keith
                                       CSNet:    keith@UChicago.CSNet
Graduate Library School                ARPA:     keith@UChicago.ARPA
University of Chicago                  Bitnet:	 kdw1%sphinx@uchicago.bitnet

ken@boring.UUCP (08/20/85)

In article <318@luke.UUCP> itkin@luke.UUCP (Steven List) writes:
>I'd like to suggest that when we put some commentary at the beginning,
>each line be preceded by the shell comment character (#).

This is a repost of a shell script that will solve the problem if every
shar'ed source has a line beginning with # at the top of the archive.
From rn I just have to say: "| (cd sourcedir; unshar)".

#! /bin/sh
# unshar - pipe shar part of input through sh
# Ignore lines before first "#" comment starting in first column.
# Input is either $1 or stdin.
sed -n '/^#/,$ p' ${1-} | exec sh
-- 
UUCP: ..!{seismo,okstate,garfield,decvax,philabs}!mcvax!ken Voice: Ken!
Mail: Centrum voor Wiskunde en Informatica, Kruislaan 413, 1098 SJ, Amsterdam.

hamilton@uiucuxc.Uiuc.ARPA (08/21/85)

>I'd like to suggest that when we put some commentary at the beginning,
>each line be preceded by the shell comment character (#).

better yet, put all your comments into a README, and put that at the
beginning of the sharchive.

jpn@panda.UUCP (John P. Nelson) (08/21/85)

In article <157@gargoyle.UUCP> ihnp4!gargoyle!keith (Keith Waclena) writes:
>Now a quick question: (our) rn always prepends a line like ``Article
>whatever from net.random'' whether I save via s or w. This screws our
>mail program; if I say ``use mbox format'' mail won't recognize the
>file as such unless I edit out that offending line.. can anyone tell
>me how to get rn to leave out that line?

The problem is in the shell script, mbox.saver

I changed this line to output a line in the format "Article: xxxx of net.foo"
turning that line into a proper header line, and so have not had any problems
with mail since.

 John P. Nelson (decvax!genrad!panda!jpn)

bogstad@HOPKINS-EECS-BRAVO.ARPA (William J. Bogstad) (08/21/85)

(Please note this was posted from the Arpanet side.  Thus, the lack
of references.)

	I, for one, dislike using a "unshar" program.  Often the only
documentation (or at least the most understandable documentation)
is in the text before the "cut here" line.  If I were to
indiscriminately use unshar I would end up with programs which
I wouldn't know how to use.

				Bill Bogstad

P.S.  Since this is unix-sources a.k.a. net.sources.....

---CUT HERE---
#! /bin/sh
# This is a shar archive and should be unpacked with /bin/sh
# Date: Wed Aug 21 11:00:22 EDT 1985
# Files: README cmd
#
echo 'sh - README'
sed 's/^X//' <<'________This_Is_The_END________' >>README
X
XThis shell script is designed to search your PATH for particular
Xinstances of a program.
________This_Is_The_END________
echo 'sh - cmd'
sed 's/^X//' <<'________This_Is_The_END________' >>cmd
XIFS=:
Xfor i
Xdo
X	for j in $PATH
X	do
X		for k in $j/$i
X		do
X			if [ -f $k ]
X			then
X				echo $k
X			fi
X		done
X	done
Xdone
________This_Is_The_END________

davidk@dartvax.UUCP (David C. Kovar) (08/23/85)

[This should *really* be moved someplace else...]

unshar can save headers, both the ones before the ----cut here -----
and mail headers.
	-o	preserve header
	-O	preserve mail header as well.

So you don't have to lose the only documentation that comes with the program
at times. (I had to look at the sources to find the option, though.)

-- 
David C. Kovar    
	    USNET:      {linus|decvax|cornell|astrovax}!dartvax!davidk%amber
	    ARPA:	davidk%amber%dartmouth@csnet-relay
	    CSNET:	davidk%amber@dartmouth

"I felt like a punk who'd gone out for a switchblade and come back
 with a tactical nuke.

 'Shit', I thought. 'Screwed again. What good's a tactical nuke in a
  street fight?'"
			"Burning Chrome" by William Gibson

john@frog.UUCP (John Woods) (08/23/85)

> The unshar program (previously posted to net.sources, I think) strips
> leading commentary in a very clever way; it strips text up to a line
> containing the words ``cut'' and ``here'' in that order and then runs
> the rest of the file through sh.

Nearly clever.  I inadvertently caused a great deal of confusion for some
people once by including an arachnid-sacrifice of

*** INSERT YOUR CUTE MESSAGE HERE ***

which I was told got interpreted as being just as good as

----------------CUT----------HERE----------------

Always a wise guy...


--
John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101
...!decvax!frog!john, ...!mit-eddie!jfw, jfw%mit-ccc@MIT-XX.ARPA

pilotti@telesoft.UUCP (Keith Pilotti @shine) (08/29/85)

In article <6589@boring.UUCP> ken@mcvax.UUCP (Amoeba #117) writes:
>In article <318@luke.UUCP> itkin@luke.UUCP (Steven List) writes:
>>I'd like to suggest that when we put some commentary at the beginning,
>>each line be preceded by the shell comment character (#).
>
>This is a repost of a shell script that will solve the problem if every
>shar'ed source has a line beginning with # at the top of the archive.
>From rn I just have to say: "| (cd sourcedir; unshar)".
>

    Starting from Ken's great idea, I fixed up this script which adds:

        o Support for multiple file names
            (eg. "unshar *" for multi-shar postings.)

        o Support for shell archives which begin with a ":"
            (old `unshar' barfs heavily...)

    ***  REPLACE YOUR `unshar' WITH THIS ONE  ***
    (ie.  "|(cd ~/bin;unshar)"  :-)

    /+\ Keith
    ________________________________________________________
    KEITH F. PILOTTI -- TeleSoft         (619) 457-2700 x172
                        10639 Roselle St, SanDiego, CA 92121

          <pilotti@telesoft.UUCP> <pilotti@UCSD.ARPA>
          ...{decvax,ucbvax}!sdcsvax!telesoft!pilotti

#! /bin/sh
cat > unshar << '@END@'
#! /bin/sh
# $Header: RCS/unshar,v 1.1 85/08/27  pilotti Exp $
#
# unshar - pipe shar part of input through sh
#
# Ignore lines before the first
#    "#" or ":" comment starting in the first column.
# Input is either $@ (ie. arg list) or stdin.
#
# NOTE: Non-BSD sites -- ln /bin/test /bin/[
#

if [ "$*" = "" ] 
then
    set - \-
fi

for shar
do
    if [ "$shar" = "-" ]
    then
        shar=""
        echo Unsharing standard-input
    else
        echo Unsharing $shar
    fi
    sed -n '/^[#:]/,$ p' ${shar-} | sh
done

@END@
chmod +x unshar
exit