Some useful ~/bin scripts: difforig

rurban on 2007-07-02T20:44:28

I found Simon Cozens entry for secret software - the stuff that lives in your ~/bin (or your /usr/local/bin if you're really brave) and never sees the light of day -, and looked into my ~/bin.

difforig originally came from the postgresql hackers, but I enhanced it to easier submit simple multifile patches in .orig-polluted working dirs. You can provide a path or multiple files.

#!/bin/sh
echo "difforig $@"
echo ""
/usr/bin/date +"%Y-%m-%d  Reini Urban "
echo ""
if [ "$#" -gt 1 -o -f "$1" ] # multiple args or a file
then
    for FILE in "$@"
    do
	ORIG="$FILE.orig"
	echo "$FILE" 1>&2
	echo "diff -ub $ORIG $FILE"
	/usr/bin/diff -ub $ORIG $FILE
    done
else 
    if [ "$#" -eq 0 ]
    then	APATH="."  # no arg: recursively all origs
    else	APATH="$1" # or one arg: recursively all origs
    fi
    find "$APATH" -name '*.orig' -print | sort \
         while read FILE
    do
	NEW="`dirname $FILE`/`basename $FILE .orig`"
	echo "$NEW" 1>&2
	echo "diff -ub $ORIG $FILE"
	/usr/bin/diff -ub $FILE $NEW
    done
fi