Subversion Repositories Projects

Rev

Rev 168 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
168 dhylands 1
#!/bin/sh
2
 
3
# getdiff.sh:
4
#
5
# A simple shell script to find the difference between the given
6
# file, say, "foo/bar" and "foo/bar.orig". The output is a 
7
# "diff -u2N" context difference preceded by "Index: " and "===="
8
# lines somewhat similar to that output by CVS. 
9
#
10
# This output can be treated as a patch against the original 
11
# file (without the ".orig" suffix) to convert it to the given 
12
# file like this:
13
#
14
#     patch -p0 < output-from-this-script
15
#
16
# Author: Ranjit Mathew (rmathew@hotmail.com)
17
#
18
 
19
if test -z $1; then
20
  echo
21
  echo ERROR: Required parameter missing!
22
  echo
23
  echo USAGE: getdiff.sh \<foo\>
24
  echo Finds the difference between the files \<foo.orig\> and \<foo\>
25
  exit 1
26
fi
27
 
28
if test ! -f $1; then
29
  echo ERROR: File $1 does not exist
30
  exit 1;
31
fi
32
 
33
if test ! -f $1.orig; then
34
  echo ERROR: File $1.orig does not exist
35
  exit 1;
36
fi
37
 
38
echo Index: $1
39
echo ===================================================================
40
NAME4SED=`echo $1 |sed 's/\\//\\\\\\//g'`
169 dhylands 41
diff -uN -U 2 $1.orig $1 |sed s/$NAME4SED\\.orig/$NAME4SED/g
168 dhylands 42
 
43
# END (getdiff.sh)