home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / gawk213b / awf < prev    next >
Encoding:
Text File  |  1993-07-29  |  1.0 KB  |  62 lines

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