Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!uw-beaver!Teknowledge.COM!unix!hplabs!hpfcso!hplisa!hpislx!bayes From: bayes@hpislx.HP.COM (Scott Bayes) Newsgroups: comp.sys.mac.programmer Subject: Re: mac sh wanted Message-ID: <9710008@hpislx.HP.COM> Date: 13 Nov 90 19:53:27 GMT References: <1990Nov10.163234.20256@cunixf.cc.columbia.edu> Organization: Measurement Systems Operation - Loveland, CO Lines: 109 > BTW: What IS the format of shell archives anyways? > ______________________________________________________________________________ > Donald Burr, c60a-cz@danube.Berkeley.edu | "I have a seperate mail-address > University of California, Berkeley | for flames and other such nega- > Majoring in Computer Science | tive msgs; it's called /dev/null." All the shell archives I've seen tend to be a procedural format. That is, the files to be archived tend to be copied as or converted to text, and packaged together with shell commands that, when executed by a shell, unpack them, put them in the right places, set their UN*X permissions, etc. Binary files tend to be converted to ASCII, and an "unpacker" program source and compilation instructions included with them (i.e. to unpack a shar [shell archive] file that contains a binary, you'll probably need a C compiler on-line). It's hard to imagine being able to un-shar a shar file without a decent emulation of a UN*X shell doing the job. Below is an example sharfile containing a binary file and a text file, both very short. The binary unpacks to contain an escape char followed by "Hello", and the text file contains "hello world". It works on an HP300 HP-UX machine Revision 7.0 or 7.03, under Bourne Shell (sh). I have seen slightly variant formats used. I created the shar with: $ shar testshar testshar2 > test.shar Scott Bayes ----------------------------------------------------------------------------- # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by Scott Bayes on Tue Nov 13 12:46:56 1990 # # This archive contains: # testshar testshar2 # LANG=""; export LANG PATH=/bin:/usr/bin:$PATH; export PATH rm -f /tmp/uud$$ (echo "begin 777 /tmp/uud$$\n \nend" | uudecode) >/dev/null 2>&1 if [ -f /tmp/uud$$ ] then rm -f /tmp/uud$$ unpacker=uudecode else echo Compiling unpacker for non-ascii files pwd=`pwd`; cd /tmp cat >unpack$$.c <<-'EOF' #include #define DEC(c) (((c) - ' ') & 077) main() { int n; char dest[128], a,b,c,d; scanf("begin %o ", &n); gets(dest); if (freopen(dest, "w", stdout) == NULL) { perror(dest); exit(1); } while ((n=getchar()) != EOF && (n=DEC(n))!=0) { while (n>0) { a = DEC(getchar()); b = DEC(getchar()); c = DEC(getchar()); d = DEC(getchar()); if (n-- > 0) putchar(a << 2 | b >> 4); if (n-- > 0) putchar(b << 4 | c >> 2); if (n-- > 0) putchar(c << 6 | d); } n=getchar(); } exit(0); } EOF cc -o unpack$$ unpack$$.c rm unpack$$.c cd $pwd unpacker=/tmp/unpack$$ fi echo x - testshar '[non-ascii]' $unpacker <<'@eof' begin 666 testshar '&TAE;&QO"AX end @eof chmod 666 testshar echo x - testshar2 cat >testshar2 <<'@EOF' hello world @EOF chmod 666 testshar2 rm -f /tmp/unpack$$ exit 0