home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / AWF.ZIP / AWF.CMD < prev    next >
OS/2 REXX Batch file  |  1991-01-23  |  1KB  |  69 lines

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