home *** CD-ROM | disk | FTP | other *** search
/ norge.freeshell.org (192.94.73.8) / 192.94.73.8.tar / 192.94.73.8 / pub / sdf / historical / unpost.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1995-01-27  |  1KB  |  73 lines

  1. #!/bin/sh
  2. #
  3. #  get uudecode items from inputlist
  4. #   -o is name of output file  will be appended to
  5. #   - is from standard input
  6. #
  7. #   all boils down to reading standard input anyway
  8. #   and writing standard output
  9. #
  10. CMD=$0 ;
  11. if [ "$*". = "." ]
  12. then 
  13. exec $CMD -
  14. fi
  15. argc=0
  16. for a in $*
  17. do
  18.     if [ ${next-0} -eq 1 ]
  19.     then
  20.     out=$a;
  21.     next=2;
  22.     continue;
  23.     fi
  24.     case $a in
  25.     -o) next=`expr ${next-0} + 1 `;;
  26.     *)  if [ -r $a ]
  27.         then
  28.         args="${args}${args+"" ""}$a" 
  29.         else
  30.         echo $CMD: "Can't read $a" 1>&2
  31.         status=1;
  32.         fi
  33.         argc=`expr ${argc-0} + 1`
  34.         ;;
  35.     esac
  36. done
  37.  
  38. if [ ${out-.} != "." ]
  39. then
  40.     $CMD ${args-} >>$out
  41.     exit $?
  42. fi
  43.  
  44. if [ ${argc-0} -ne 0 -a "${args-.}" = "." ]
  45. then
  46. exit $status
  47. fi
  48.  
  49. /usr/bin/awk 'BEGIN{
  50.     on=0;
  51.     mode=0;
  52.     copy=0;
  53.     ALLOW=" !\"#$%&'"'"'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`";
  54. }
  55. /^BEGIN/{mode = 1 ; copy = 1 ;next; }
  56. /^END/{if ( mode  == 1 ) copy = 0 ;next;}
  57. mode == 1 && copy == 1 {print $0 ; next; };
  58. mode == 1 { next;}
  59. NF == 3 && /^begin /{print $0;on=1;next;};
  60. on == 1 && /^end/{on=0;if( space) printf("\n");printf("%s\n",$0);next;}
  61. on == 1 {
  62.     if( length($0) == 0 ){
  63.     space=1;
  64.     next;
  65.     }else space=0;
  66. }
  67. on != 1{ next;}
  68. on != 1 ||/^--/||/^ /||/[a-z{|}]/{next;}
  69. {print $0;}
  70. ' $args
  71. status=`expr ${status-0} + $?`
  72. exit $status
  73.