common/bin/diffexec.sh

Print this page




  32   echo "4 - Differences, content AND size"
  33   echo "10 - Could not perform diff"
  34   echo "Use 'quiet' to disable any output."
  35   echo "Syntax: $0 file1 file2 [quiet]"
  36   exit 10
  37 fi
  38 
  39 if [ ! -f $1 ]
  40 then
  41   echo $1 does not exist
  42   exit 10
  43 fi
  44 
  45 if [ ! -f $2 ]
  46 then
  47   echo $2 does not exist
  48   exit 10
  49 fi
  50 
  51 if [ "`uname`" == "SunOS" ]; then



  52     NM=gnm
  53     STAT="gstat -c%s"



  54     LDD=ldd
  55 elif [ $OSTYPE == "cygwin" ]; then
  56     NM="$VS100COMNTOOLS/../../VC/bin/amd64/dumpbin.exe"
  57     NM_ARGS=/exports
  58     STAT="stat -c%s"
  59     LDD=
  60 elif [ "`uname`" == "Darwin" ]; then
  61     NM=nm
  62     STAT="stat -f%z"
  63     LDD="otool -L"
  64 else
  65     NM=nm
  66     STAT="stat -c%s"
  67     LDD=ldd
  68 fi
  69 
  70 # Should the differences be viewed?
  71 VIEW=
  72 # You can do export DIFF=meld to view
  73 # any differences using meld instead.
  74 if [ -n "$DIFF" ]; then
  75     DIFF="$DIFF"
  76 else
  77     DIFF=diff
  78 fi
  79 OLD=$(cd $(dirname $1) && pwd)/$(basename $1)
  80 NEW=$(cd $(dirname $2) && pwd)/$(basename $2)
  81 
  82 OLD_SIZE=$($STAT "$OLD")
  83 NEW_SIZE=$($STAT "$NEW")
  84 
  85 if [ $# -gt 3 ]
  86 then
  87     ROOT1=$(cd $3 && pwd)
  88     ROOT2=$(cd $4 && pwd)
  89     OLD_NAME=$(echo $OLD | sed "s|$ROOT1/||")
  90     NEW_NAME=$(echo $NEW | sed "s|$ROOT2/||")
  91     if [ "x$5" == "xview" ]; then VIEW=view; fi
  92 else
  93     ROOT1=$(dirname $OLD)/
  94     ROOT2=$(dirname $NEW)/
  95     OLD_NAME=$OLD
  96     NEW_NAME=$NEW
  97     if [ "x$3" == "xview" ]; then VIEW=view; fi
  98 fi
  99 
 100 if cmp $OLD $NEW > /dev/null
 101 then
 102     # The files were bytewise identical.
 103     echo Identical: $OLD_NAME




  32   echo "4 - Differences, content AND size"
  33   echo "10 - Could not perform diff"
  34   echo "Use 'quiet' to disable any output."
  35   echo "Syntax: $0 file1 file2 [quiet]"
  36   exit 10
  37 fi
  38 
  39 if [ ! -f $1 ]
  40 then
  41   echo $1 does not exist
  42   exit 10
  43 fi
  44 
  45 if [ ! -f $2 ]
  46 then
  47   echo $2 does not exist
  48   exit 10
  49 fi
  50 
  51 if [ "`uname`" == "SunOS" ]; then
  52     if [ -f "`which nm`" ]; then
  53         NM=nm
  54     elif [ -f "`which gnm`" ]; then
  55         NM=gnm
  56     else
  57         echo "No nm command found"
  58         exit 10
  59     fi
  60     LDD=ldd
  61 elif [ $OSTYPE == "cygwin" ]; then
  62     NM="$VS100COMNTOOLS/../../VC/bin/amd64/dumpbin.exe"
  63     NM_ARGS=/exports

  64     LDD=
  65 elif [ "`uname`" == "Darwin" ]; then
  66     NM=nm

  67     LDD="otool -L"
  68 else
  69     NM=nm

  70     LDD=ldd
  71 fi
  72 
  73 # Should the differences be viewed?
  74 VIEW=
  75 # You can do export DIFF=meld to view
  76 # any differences using meld instead.
  77 if [ -n "$DIFF" ]; then
  78     DIFF="$DIFF"
  79 else
  80     DIFF=diff
  81 fi
  82 OLD=$(cd $(dirname $1) && pwd)/$(basename $1)
  83 NEW=$(cd $(dirname $2) && pwd)/$(basename $2)
  84 
  85 OLD_SIZE=$(ls -l "$OLD" | awk '{ print $5 }')
  86 NEW_SIZE=$(ls -l "$NEW" | awk '{ print $5 }')
  87 
  88 if [ $# -gt 3 ]
  89 then
  90     ROOT1=$(cd $3 && pwd)
  91     ROOT2=$(cd $4 && pwd)
  92     OLD_NAME=$(echo $OLD | sed "s|$ROOT1/||")
  93     NEW_NAME=$(echo $NEW | sed "s|$ROOT2/||")
  94     if [ "x$5" == "xview" ]; then VIEW=view; fi
  95 else
  96     ROOT1=$(dirname $OLD)/
  97     ROOT2=$(dirname $NEW)/
  98     OLD_NAME=$OLD
  99     NEW_NAME=$NEW
 100     if [ "x$3" == "xview" ]; then VIEW=view; fi
 101 fi
 102 
 103 if cmp $OLD $NEW > /dev/null
 104 then
 105     # The files were bytewise identical.
 106     echo Identical: $OLD_NAME