[comp.sources.wanted] "Safe" unshar

lmb@vsi1.UUCP (Larry Blair) (11/24/88)

I'm looking for a version of unshar that does not execute the file it is
unshar'ing.  The version that I last pulled of the net ultimately passes
the file to sh for execution.
-- 
Larry Blair   ames!vsi1!lmb   lmb%vsi1.uucp@ames.arc.nasa.gov

bin@primate.wisc.edu (Brain in Neutral) (11/26/88)

From article <1240@vsi1.UUCP>, by lmb@vsi1.UUCP (Larry Blair):
> I'm looking for a version of unshar that does not execute the file it is
> unshar'ing.  The version that I last pulled of the net ultimately passes
> the file to sh for execution.

What is it supposed to do, then?  Just print the commands it thinks it's
supposed to execute?  You could use Brandon Allbery's uns and change
sh to sh -nv:

	#!/bin/sh
	#: uns -- unpack shell archives (named or on stdin)
	if test -z "$*"; then set x -; shift 1; fi
	for arg in "$@"; do
		echo "shar: unpacking ${arg}"
		sed -e '1,/^[:#]/d' "$arg" | sh -nv
	done

But the problem is that the here-files are also printed as sh is going
through them...

Paul DuBois
dubois@primate.wisc.edu	rhesus!dubois
bin@primate.wisc.edu	rhesus!bin

dg@lakart.UUCP (David Goodenough) (11/28/88)

From article <440@rhesus.primate.wisc.edu>, by bin@primate.wisc.edu (Brain in Neutral):
> From article <1240@vsi1.UUCP>, by lmb@vsi1.UUCP (Larry Blair):
>> I'm looking for a version of unshar that does not execute the file it is
>> unshar'ing.  The version that I last pulled of the net ultimately passes
>> the file to sh for execution.
> 
> What is it supposed to do, then?  Just print the commands it thinks it's
> supposed to execute?

What it does, is to look for lines of the form:

sed 's/^X//' > file.xyz << FunkyStuff

get the ^X, file.xyz and FunkyStuff out, open file.xyz for output,
read the input shar till it finds a line FunkyStuff, and trim X off the
start of every line. Just like the version I have does. If anyone is
interested I can post it to comp.sources.misc, which I think is where
I got it from (or maybe it came from comp.sources.unix). Comments Mr.
Albery? or Mr. Salz?

As an aside I can personally vouch that it doesn't need /bin/sh
to operate: it has even been ported to CP/M. So there :-P ( :-) )
-- 
	dg@lakart.UUCP - David Goodenough		+---+
							| +-+-+
	....... !harvard!xait!lakart!dg			+-+-+ |
AKA:	dg%lakart.uucp@harvard.harvard.edu	  	  +---+

ok@quintus.uucp (Richard A. O'Keefe) (11/30/88)

In article <346@lakart.UUCP> dg@lakart.UUCP (David Goodenough) writes:
>What it does, is to look for lines of the form:
>
>sed 's/^X//' > file.xyz << FunkyStuff
>
>get the ^X, file.xyz and FunkyStuff out, open file.xyz for output,
>read the input shar till it finds a line FunkyStuff, and trim X off the

It might be a good idea to be a wee bit more flexible.  Not everyone uses
StuffyFunk.  (The sharchiver I have uses lines like
	sed -e 's/^X//' >file <<'------ EOF ------'
and I have considered changing it to use
	<<'------ EOF ------' sed -e 's/^X//' >file
so that the variable part of the line would always start at a fixed column.
I've noticed several other end-of-file markers in use on the net.

dg@lakart.UUCP (David Goodenough) (12/03/88)

From article <781@quintus.UUCP>, by ok@quintus.uucp (Richard A. O'Keefe):
] In article <346@lakart.UUCP> dg@lakart.UUCP (I) write:
]>What it does, is to look for lines of the form:
]>
]>sed 's/^X//' > file.xyz << FunkyStuff
]>
]>get the ^X, file.xyz and FunkyStuff out, open file.xyz for output,
]>read the input shar till it finds a line FunkyStuff, and trim X off the
] 
] It might be a good idea to be a wee bit more flexible.  Not everyone uses
] StuffyFunk.  (The sharchiver I have uses lines like
] 	sed -e 's/^X//' >file <<'------ EOF ------'
] and I have considered changing it to use
] 	<<'------ EOF ------' sed -e 's/^X//' >file
] so that the variable part of the line would always start at a fixed column.
] I've noticed several other end-of-file markers in use on the net.

My apologies for not being clear. It parses the line, and takes whatever text
it finds after the << as the "end of file word". Hence it will grok my shars
that say '##__EOF..file.c__##' just as happily as those that say Funky_Stuff
or RoNnIe_RaYgUn or whatever. I've just added a bit of code to spot mkdirs,
and do those, so it now can handle (e.g.) the wanderer shars that required
the creation of a directory to hold the screens.

However, it DOES rely on the sed (or cat) being the first thing on the line,
so saying:
<<\Grok_This sed -e 's/^X//' > file.c
would (unfortunately) slip past it.
-- 
	dg@lakart.UUCP - David Goodenough		+---+
							| +-+-+
	....... !harvard!xait!lakart!dg			+-+-+ |
AKA:	dg%lakart.uucp@harvard.harvard.edu	  	  +---+

mju@m-net.UUCP (Marc Unangst) (12/04/88)

In article <440@rhesus.primate.wisc.edu> bin@primate.wisc.edu (Brain in Neutral) writes:
>From article <1240@vsi1.UUCP>, by lmb@vsi1.UUCP (Larry Blair):
>> I'm looking for a version of unshar that does not execute the file it is
>> unshar'ing.  The version that I last pulled of the net ultimately passes
>> the file to sh for execution.
>
>What is it supposed to do, then?  Just print the commands it thinks it's
>supposed to execute?  You could use Brandon Allbery's uns and change

There is an unshar program for MS-DOS that has most of the commands
used in shar files built-in: if, test, sed, cat, etc.  A program for
Unix that screened each command before it was executed wouldn't
be that hard to write.
-- 
"Don't find a fault. | Marc Unangst
Find a remedy."      | UUCP: mju@m-net.ann-arbor.mi.us
  -Henry Ford        | UUCP path: ...!uunet!umix!m-net!mju
---------------------+ Internet: mju%m-net@umix.cc.umich.edu