#!/bin/csh -f # windiff # ----------------------------------------------------------------------------- # C shell script to compare 2 directory trees. # Compare the specified files or folders via DeltaWalker, if installed, which # allows you to view differences, reconcile them, edit the files, search # within the files, etc. Otherwise, compare via standard Unix diff. # ----------------------------------------------------------------------------- # Revision History: # $Log$ # ----------------------------------------------------------------------------- set deltawalker = "/Applications/DeltaWalker.app/Contents/MacOS/DeltaWalker" if (-e $deltawalker:q) then # $PWD Explicitly convert the relative paths to absolute, if necessary, # since DeltaWalker ignores the current directory and assumes it got # full pathnames. # Note: This also has the nice side effect of filling in the current # directory as defaults for both params when omitted, so that it # starts out comparing current directory to itself, and the user # can navigate from there. # & Run as a background process so that this script can complete # immediately. # No. Bad idea. Require the user to specify it when calling the # script instead, in typical Unix style. Then the user can specify # it or not, while if we did it automatically, he'd have no way to # omit it. # Quotes required in case filenames have spaces and come in with them # escaped with backslashes that get stripped off on the way in. # Note: Must be double quotes, not single. Otherwise $PWD is not # expanded. # Note: -vmargs -X... must be at very end of command line # Assume file 1 is a relative filename. set file1 = "$PWD/$1" # If not found relative, assume file 1 is an absolute filename. if (! -e $file1:q) set file1 = $1:q # Assume file 2 is a relative filename. set file2 = "$PWD/$2" # If file 2 is a relative directory, use the same named file 1 inside it. if (-d $file2:q && -e $file2:q/$1:q) set file2 = $file2:q/$1:q # If not found relative, assume file 2 is an absolute filename. if (! -e $file2:q) set file2 = $2:q # If file 2 is an absolute directory, use the same named file 1 inside it. if (-d $file2:q && -e $file2:q/$1:q) set file2 = $file2:q/$1:q $deltawalker:q -mi -nosplash "$file1" "$file2" -vmargs -Xmx1024M # The following didn't work because there was no way to pass command line # options and args to DeltaWalker. It always opened empty, and used splash # screen. # -n New instance of DeltaWalker, even if another instance is already open. # open -n -a '/Applications/DeltaWalker.app' $* # ?? How to specify DeltaWalker options like: -mi -nosplash else diff -r $*:q | less # -r = Recursive # You may prefer the following: # diff -r -y -W 200 $*:q | less # -r = Recursive # -y = Side-by-side output # -W 200 = 200 columns wide for side-by-side output endif