home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / AWF.ZIP / AWF.SH < prev    next >
Text File  |  1991-01-23  |  1KB  |  68 lines

  1. # DOS version
  2. swap xms
  3.  
  4. # AWFLIB is where the pieces live
  5. AWFLIB=c:/bin/awf
  6.  
  7. pass2=$TMP/awp$$    # tempfile for building pass 2
  8. errs=$TMP/awe$$        # error messages (awk can't send to stderr)
  9. input=$TMP/awi$$    # tempfile for input file(s)
  10.  
  11. case "$1" in
  12. -ms)    mac=ms    ;;
  13. -man)    mac=man    ;;
  14. *)    echo "$0: must specify -ms or -man" >&2
  15.     exit 2
  16.     ;;
  17. esac
  18.  
  19. shift
  20.  
  21. dev="$AWFLIB/$TERM.dev"
  22.  
  23. if test ! -r $dev
  24. then
  25.     dev="$AWFLIB/dumb.dev"
  26. fi
  27.  
  28. # build the full, macro-set-dependent, pass-2 awk program
  29.  
  30. sed -n '1,/^#include/p' $AWFLIB/pass2 >$pass2
  31. cat $AWFLIB/${mac}.p2 >>$pass2
  32. sed -n '/^#include/,$p' $AWFLIB/pass2 >>$pass2
  33.  
  34. # do it
  35.  
  36. echo ".^x $errs" >$input
  37. echo ".^b" >>$input
  38. echo ".^# 1 <prolog>" >>$input
  39.  
  40. cat $dev $AWFLIB/common $AWFLIB/${mac}.mac >>$input
  41.  
  42. if test " $*" = " "
  43. then
  44.     echo ".^# 1 <stdin>" >>$input
  45.     cat - >>$input
  46. else
  47.     for f
  48.     do
  49.         echo ".^# 1 $f" >>$input
  50.         cat $f >>$input
  51.     done
  52. fi
  53.  
  54. echo ".^e" >>$input
  55.  
  56. gawk -f $AWFLIB/pass1 $input | gawk -f $pass2 | gawk -f $AWFLIB/pass3
  57.  
  58. # error messages, if any
  59. if test -s $errs
  60. then
  61.     cat $errs >&2
  62.     rm -f $pass2 $errs $input >nul
  63.     exit 1
  64. else
  65.     rm -f $pass2 $errs $input >nul
  66.     exit 0
  67. fi
  68.