home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / src / amiga / ed-0.1-src.lha / ed-0.1 / test / mkscripts.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1994-01-20  |  1.3 KB  |  74 lines

  1. #!/bin/sh -
  2. # This script generates ed test scripts (.ed) from .t files
  3.  
  4. PATH="/bin:/usr/bin:/usr/local/bin/:."
  5. ED=$1
  6. [ ! -x $ED ] && { echo "$ED: cannot execute"; exit 1; }
  7.  
  8. for i in *.t; do
  9. #    base=${i%.*}
  10. #    base=`echo $i | sed 's/\..*//'`
  11. #    base=`expr $i : '\([^.]*\)'`
  12. #    (
  13. #    echo "#!/bin/sh -"
  14. #    echo "$ED - <<\EOT"
  15. #    echo "r $base.d"
  16. #    cat $i
  17. #    echo "w $base.o"
  18. #    echo EOT
  19. #    ) >$base.ed
  20. #    chmod +x $base.ed
  21. # The following is pretty ugly way of doing the above, and not appropriate 
  22. # use of ed  but the point is that it can be done...
  23.     base=`$ED - \!"echo $i" <<-EOF
  24.         s/\..*
  25.     EOF`
  26.     $ED - <<-EOF
  27.         a
  28.         #!/bin/sh -
  29.         $ED - <<\EOT
  30.         H
  31.         r $base.d
  32.         w $base.o
  33.         EOT
  34.         .
  35.         -2r $i
  36.         w $base.ed
  37.         !chmod +x $base.ed
  38.     EOF
  39. done
  40.  
  41. for i in *.err; do
  42. #    base=${i%.*}
  43. #    base=`echo $i | sed 's/\..*//'`
  44. #    base=`expr $i : '\([^.]*\)'`
  45. #    (
  46. #    echo "#!/bin/sh -"
  47. #    echo "$ED - <<\EOT"
  48. #    echo H
  49. #    echo "r $base.err"
  50. #    cat $i
  51. #    echo "w $base.o"
  52. #    echo EOT
  53. #    ) >$base.red
  54. #    chmod +x $base.red
  55. # The following is pretty ugly way of doing the above, and not appropriate 
  56. # use of ed  but the point is that it can be done...
  57.     base=`$ED - \!"echo $i" <<-EOF
  58.         s/\..*
  59.     EOF`
  60.     $ED - <<-EOF
  61.         a
  62.         #!/bin/sh -
  63.         $ED - <<\EOT
  64.         H
  65.         r $base.err
  66.         w $base.o
  67.         EOT
  68.         .
  69.         -2r $i
  70.         w ${base}.red
  71.         !chmod +x ${base}.red
  72.     EOF
  73. done
  74.