#!/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$ # ----------------------------------------------------------------------------- # Collect command line options set option_quiet = "false" set option_nowait = "false" while ($#argv > 0) if ("$1" == "-h" || "$1" == "--help") then echo "Usage: $0:t [options]" echo "Options:" echo " -h = Show this help text" echo " --help = Show this help text" echo " -q = Quiet. Do not echo command" echo " --quiet = Quiet. Do not echo command" echo " -n = Do not wait for interactive diff to exit" echo " --nowait = Do not wait for interactive diff to exit" exit 1 else if ("$1" == "-q" || "$1" == "--quiet") then shift set option_quiet = "true" else if ("$1" == "-n" || "$1" == "--nowait") then shift set option_nowait = "true" else if ("-" == "`echo $1:q | cut -c 1`") then echo "Error: Invalid option: $1:q" $0 --help exit 1 else # Not a recognized option. Assume it's the first argument break endif end set deltawalker = "/Applications/DeltaWalker.app/Contents/MacOS/DeltaWalker" #set deltawalker = "/Applications/DeltaWalker.1.9.5.app/Contents/MacOS/DeltaWalker" #set deltawalker = "/Applications/DeltaWalker.2.2.0.app/Contents/MacOS/DeltaWalker" #set deltawalker = "/Applications/DeltaWalker.2.2.2.preview.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 # Options, per http://www.deltawalker.com/integrate/command-line.jsp: # -mi = Force new instance of DeltaWalker app # -nosplash = No splash screen (obsolete option in 2.2.0? Not listed # in doc page above, and seems to never do a splash screen # now anyhow) # # Yoli at DeltaWalker supoport says this now defaults to -vmargs -Xmx4G. # So, no need to specify it here. Let the tool decide for me in the # future. #$deltawalker:q -mi -nosplash "$file1" "$file2" -vmargs -Xmx1024M #$deltawalker:q -mi -nosplash "$file1" "$file2" -vmargs -Xmx4G if (${option_quiet} == "false") then echo $0:t "$file1" "$file2" endif # (set echo; $deltawalker:q -mi -nosplash "$file1" "$file2") if ("$option_nowait" == "true") then # Note: This only works because we've already converted the file # pathnames to absolute. Relative filename don't work when # using & to spawn a separate process. # Might someday want to write a spawncd script to generate # a temp script that does a cd to the current folder and # calls the specified command, then use & to spawn a separate # process to call the temp script, then delete the temp # script. Why doesn't & already inherit the cwd? # Doesn't seem to with deltawalker anyhow. # Oops! It DOES do that already and works fine with deltawalker. # No need of for this nowait option. Could just delete it, but # it might be useful as a script called from a pipe or something # where & doesn't work. Or as an example of how to do this # Leave it for now. $deltawalker:q -mi -nosplash "$file1" "$file2" & else $deltawalker:q -mi -nosplash "$file1" "$file2" endif # 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