"Fossies" - the Fresh Open Source Software Archive

Member "grzip-0.3.0/scripts/grzdiff" (31 Jan 2007, 2170 Bytes) of package /linux/privat/old/grzip-0.3.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 # sh is buggy on RS/6000 AIX 3.2. Replace above line with #!/bin/ksh
    3 
    4 # Grzcmp/diff wrapped for grzip, 
    5 # adapted from zdiff by Simon Matter <simon.matter@invoca.ch>
    6 # for Invoca Linux Server.
    7 
    8 # Grzcmp and grzdiff are used to invoke the cmp or the  diff  pro-
    9 # gram  on compressed files.  All options specified are passed
   10 # directly to cmp or diff.  If only 1 file is specified,  then
   11 # the  files  compared  are file1 and an uncompressed file1.gz.
   12 # If two files are specified, then they are  uncompressed  (if
   13 # necessary) and fed to cmp or diff.  The exit status from cmp
   14 # or diff is preserved.
   15 
   16 PATH="/usr/bin:$PATH"; export PATH
   17 prog=`echo $0 | sed 's|.*/||'`
   18 case "$prog" in
   19   *cmp) comp=${CMP-cmp}   ;;
   20   *)    comp=${DIFF-diff} ;;
   21 esac
   22 
   23 OPTIONS=
   24 FILES=
   25 for ARG
   26 do
   27     case "$ARG" in
   28     -*) OPTIONS="$OPTIONS $ARG";;
   29      *) if test -f "$ARG"; then
   30             FILES="$FILES $ARG"
   31         else
   32             echo "${prog}: $ARG not found or not a regular file"
   33         exit 1
   34         fi ;;
   35     esac
   36 done
   37 if test -z "$FILES"; then
   38     echo "Usage: $prog [${comp}_options] file [file]"
   39     exit 1
   40 fi
   41 tmp=`/bin/mktemp ${TMPDIR:-/tmp}/grzdiff.XXXXXXXXXX` || {
   42       echo 'cannot create a temporary file' >&2
   43       exit 1
   44 }
   45 set $FILES
   46 if test $# -eq 1; then
   47     FILE=`echo "$1" | sed 's/.grz$//'`
   48     grzip -c -d "$FILE.grz" | $comp $OPTIONS - "$FILE"
   49     STAT="$?"
   50 
   51 elif test $# -eq 2; then
   52     case "$1" in
   53         *.grz)
   54                 case "$2" in
   55             *.grz)
   56             F=`echo "$2" | sed 's|.*/||;s|.grz$||'`
   57                         grzip -c -d -f -q "$2" > $tmp
   58                         grzip -c -d -f -q "$1" | $comp $OPTIONS - $tmp
   59                         STAT="$?"
   60             /bin/rm -f $tmp;;
   61 
   62                 *)      grzip -c -d -f -q "$1" | $comp $OPTIONS - "$2"
   63                         STAT="$?";;
   64                 esac;;
   65         *)      case "$2" in
   66             *.grz)
   67                         grzip -c -d -f -q "$2" | $comp $OPTIONS "$1" -
   68                         STAT="$?";;
   69                 *)      $comp $OPTIONS "$1" "$2"
   70                         STAT="$?";;
   71                 esac;;
   72     esac
   73         exit "$STAT"
   74 else
   75     echo "Usage: $prog [${comp}_options] file [file]"
   76     exit 1
   77 fi