home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cproto.zip / cproto46 / testing / make_bat.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1998-01-24  |  1KB  |  61 lines

  1. #!/bin/sh
  2. # $Id: make_bat.sh,v 4.3 1998/01/24 01:42:13 cthuang Exp $
  3. #
  4. # This makes a special ".bat" file for testing CPROTO on MSDOS.
  5. # It won't work properly if /bin/echo tries to expand the backslash sequences.
  6. # (This is the case on SunOS 4.1.x).
  7. #
  8. # The MSDOS 'fc' program doesn't return an exit code for differing files.
  9. # We have to examine the output log...
  10. TMP=make$$
  11. rm -f $TMP
  12. trap "rm -f $TMP" 0 1 2 5 15
  13. if [ -f /bin/echo ]
  14. then
  15.     ECHO=/bin/echo
  16. else
  17.     ECHO=echo
  18. fi
  19. for i in $*
  20. do
  21.     i="`echo $i | sed -e 's/[A-Za-z_.]//g'`"
  22.     I="case$i"
  23.     if [ -n "$i" -a ! -f $I.bat ]
  24.     then
  25.         echo '** making '$I.bat
  26.         cat >$I.bat <<EOF
  27. @echo off
  28. echo Testing case $i
  29. echo Testing case $i >>run_test.out
  30. if exist $I.out erase $I.out
  31. if exist $I.dif erase $I.dif
  32. copy syntax.c $I.c
  33. EOF
  34.         grep 'CASE[     ]'$i run_test.txt >$TMP
  35.         OPTS=`sed -e 's/^.*=/CPROTO/' $TMP`
  36.         TEST=`sed -e 's/^.*=/CPROTO/' -e 's/-[at]//' $TMP`
  37.         sed    -e 's/^.*=/CPROTO/' $TMP | \
  38.         sed    -e 's/^/..\\/' \
  39.             -e s/\$/\ -o$I.out\ -O$I.err\ $I.c/ \
  40.             -e s/\"//g >>$I.bat
  41.         if [ ".$OPTS" !=  ".$TEST" ]
  42.         then
  43.         cat >>$I.bat <<EOF
  44. echo ... edited $I.c ... >>$I.out
  45. type $I.c >>$I.out
  46. EOF
  47.         fi
  48.         cat >>$I.bat <<EOF
  49. if not exist $I.ref goto saveit
  50.     fc/L/n/w $I.out $I.ref >>run_test.out
  51.     if exist $I.out erase $I.out
  52.     if exist $I.err erase $I.err
  53.     goto end
  54. :saveit
  55.     ren $I.out $I.ref
  56. :end
  57.     erase $I.c
  58. EOF
  59.     fi
  60. done
  61.