home *** CD-ROM | disk | FTP | other *** search
/ BUG 1 / BUGCD1996_0708.ISO / pc / util / minilin / minilin.exe / USR / BIN / ZDIFF < prev    next >
Text File  |  1994-05-19  |  2KB  |  68 lines

  1. #!/bin/sh
  2. # Zcmp and zdiff are used to invoke the cmp or the  diff  pro-
  3. # gram  on compressed files.  All options specified are passed
  4. # directly to cmp or diff.  If only 1 file is specified,  then
  5. # the  files  compared  are file1 and an uncompressed file1.gz.
  6. # If two files are specified, then they are  uncompressed  (if
  7. # necessary) and fed to cmp or diff.  The exit status from cmp
  8. # or diff is preserved.
  9.  
  10. PATH="BINDIR:$PATH"; export PATH
  11. prog=`echo $0 | sed 's|.*/||'`
  12. case "$prog" in
  13.   *cmp) comp=${CMP-cmp}   ;;
  14.   *)    comp=${DIFF-diff} ;;
  15. esac
  16.  
  17. OPTIONS=
  18. FILES=
  19. for ARG
  20. do
  21.     case "$ARG" in
  22.     -*)    OPTIONS="$OPTIONS $ARG";;
  23.      *)    if test -f "$ARG"; then
  24.             FILES="$FILES $ARG"
  25.         else
  26.             echo "${prog}: $ARG not found or not a regular file"
  27.         exit 1
  28.         fi ;;
  29.     esac
  30. done
  31. if test -z "$FILES"; then
  32.     echo "Usage: $prog [${comp}_options] file [file]"
  33.     exit 1
  34. fi
  35. set $FILES
  36. if test $# -eq 1; then
  37.     FILE=`echo "$1" | sed 's/[-.][zZtga]*$//'`
  38.     gzip -cd "$1" | $comp $OPTIONS - "$FILE"
  39.     STAT="$?"
  40.  
  41. elif test $# -eq 2; then
  42.     case "$1" in
  43.         *[-.]gz | *[-.][zZ] | *.t[ga]z)
  44.                 case "$2" in
  45.             *[-.]gz | *[-.][zZ] | *.t[ga]z)
  46.             F=`echo "$2" | sed 's|.*/||;s|[-.][zZtga]*$||'`
  47.                         gzip -cd "$2" > /tmp/"$F".$$
  48.                         gzip -cd "$1" | $comp $OPTIONS - /tmp/"$F".$$
  49.                         STAT="$?"
  50.             /bin/rm -f /tmp/"$F".$$;;
  51.  
  52.                 *)      gzip -cd "$1" | $comp $OPTIONS - "$2"
  53.                         STAT="$?";;
  54.                 esac;;
  55.         *)      case "$2" in
  56.             *[-.]gz | *[-.][zZ] | *.t[ga]z)
  57.                         gzip -cd "$2" | $comp $OPTIONS "$1" -
  58.                         STAT="$?";;
  59.                 *)      $comp $OPTIONS "$1" "$2"
  60.                         STAT="$?";;
  61.                 esac;;
  62.     esac
  63.         exit "$STAT"
  64. else
  65.     echo "Usage: $prog [${comp}_options] file [file]"
  66.     exit 1
  67. fi
  68.