home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2023 < prev    next >
Internet Message Format  |  1990-12-28  |  2KB

  1. From: falk@peregrine.Sun.COM (Ed Falk)
  2. Newsgroups: alt.sources
  3. Subject: Re: SHAR - Where is the source ?
  4. Message-ID: <2046@exodus.Eng.Sun.COM>
  5. Date: 4 Nov 90 01:30:00 GMT
  6.  
  7. In article <9010311326.AA02589@w107zrz.zrz.tu-berlin.de> Frank Elsner <elsner@zrz.tu-berlin.de> writes:
  8. >Where can I get the source of "shar" to be used with INTERACTIVE UNIX ?
  9. >
  10. >Unfortunatly "shar" is missing but I need it .
  11. >
  12. >Frank Elsner (TUBerlin/ZRZ, Postmaster)
  13.  
  14.  
  15. "shar" is not part of standard Unix, it's just a utility people
  16. pass around.  There are at least a dozen variations.
  17.  
  18. Here's the one I use 90% of the time:  It doesn't do any of the
  19. fancy stuff like compressing binary files or building multi-part
  20. archives, but it works for just packing a bunch of files.  It's
  21. main advantage is that it's a short shell script rather than a
  22. C program.
  23.  
  24.  
  25. #! /bin/sh
  26. #    shar <source1> <source2> ... <sourceN> [ > destination ]
  27.  
  28. echo "#! /bin/sh"
  29. echo "# this is a shell archive, meaning:"
  30. echo "# 1. Remove everything above the #! /bin/sh line"
  31. echo "# 2. Save the resulting text in a file."
  32. echo "# 3. Execute the file with /bin/sh to create the files:"
  33. for i in $* ; do
  34.   echo "#    $i"
  35. done
  36. echo "# This archive created: `date` by $USER"
  37. echo "#"
  38. echo "#"
  39. echo 'export PATH; PATH=/bin:$PATH'
  40. echo "#"
  41.  
  42. for i do
  43.   echo a - $i >&2
  44.   echo ""
  45.   len=`wc -c < $i`
  46.   echo "if test -f $i"
  47.   echo "then"
  48.   echo "echo shar: will not over-write existing file $i"
  49.   echo "else"
  50.   echo "echo shar: extracting '$i', $len characters"
  51.   echo "sed 's/^X//' > $i <<'SHAR_EOF'"
  52.   sed 's/^/X/' $i
  53.   echo "SHAR_EOF"
  54.   echo "len=\`wc -c < $i\`"
  55.   echo "if test \$len != $len ; then"
  56.   echo "echo error: $i was \$len bytes long, should have been $len"
  57.   echo "fi"
  58.   echo "fi # end of overwriting check"
  59. done
  60. echo "exit 0"
  61.     -ed falk, sun microsystems -- sun!falk, falk@sun.com
  62.     "What are politicians going to tell people when the
  63.     Constitution is gone and we still have a drug problem?"
  64.             -- William Simpson, A.C.L.U.
  65.