home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / progs / shar.icn < prev    next >
Text File  |  2000-07-29  |  2KB  |  63 lines

  1. ############################################################################
  2. #
  3. #    File:     shar.icn
  4. #
  5. #    Subject:  Program to create UNIX shell archive
  6. #
  7. #    Author:   Robert J. Alexander
  8. #
  9. #    Date:     May 6, 1992
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  Program to create Bourne shell archive of text files.
  18. #
  19. #  Usage: shar text_file...
  20. #
  21. ############################################################################
  22.  
  23. procedure main(arg)
  24.    local fn, chars, f, line
  25.  
  26.    write(
  27.       "#! /bin/sh_
  28.      \n# This is a shell archive, meaning:_
  29.      \n# 1. Remove everything above the #! /bin/sh line._
  30.      \n# 2. Save the resulting text in a file._
  31.      \n# 3. Execute the file with /bin/sh (not csh) to create:")
  32.    every write("#\t",!arg)
  33.    write(
  34.       "# This archive created: ",&dateline,
  35.        "\nexport PATH; PATH=/bin:/usr/bin:$PATH")
  36.    every fn := !arg do {
  37.       chars := 0
  38.       f := open(fn) | stop("Can't open \",fn,"\"")
  39.       write(
  40.          "if test -f '",fn,"'_
  41.         \nthen_
  42.         \n\techo shar: \"will not over-write existing file '",fn,"'\"_
  43.         \nelse_
  44.         \ncat << \\SHAR_EOF > '",fn,"'")
  45.       while line := read(f) do {
  46.      write(line)
  47.      chars +:= *line + 1
  48.      }
  49.       write(
  50.         "SHAR_EOF_
  51.         \nif test ",chars," -ne \"`wc -c < '",fn,"'`\"_
  52.         \nthen_
  53.         \n\techo shar: \"error transmitting '",fn,"'\" '(should have been ",
  54.           chars," characters)'_
  55.         \nfi_
  56.         \nfi")
  57.       close(f)
  58.       }
  59.    write(
  60.       "exit 0_
  61.      \n#\tEnd of shell archive")
  62. end
  63.