3
# Copyright (c) 1994 - 2010, Lawrence Livermore National Security, LLC.
7
# This file is part of Silo. For details, see silo.llnl.gov.
9
# Redistribution and use in source and binary forms, with or without
10
# modification, are permitted provided that the following conditions
13
# * Redistributions of source code must retain the above copyright
14
# notice, this list of conditions and the disclaimer below.
15
# * Redistributions in binary form must reproduce the above copyright
16
# notice, this list of conditions and the disclaimer (as noted
17
# below) in the documentation and/or other materials provided with
19
# * Neither the name of the LLNS/LLNL nor the names of its
20
# contributors may be used to endorse or promote products derived
21
# from this software without specific prior written permission.
23
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE
27
# LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR
28
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
# This work was produced at Lawrence Livermore National Laboratory under
37
# Contract No. DE-AC52-07NA27344 with the DOE. Neither the United
38
# States Government nor Lawrence Livermore National Security, LLC nor
39
# any of their employees, makes any warranty, express or implied, or
40
# assumes any liability or responsibility for the accuracy,
41
# completeness, or usefulness of any information, apparatus, product, or
42
# process disclosed, or represents that its use would not infringe
43
# privately-owned rights. Any reference herein to any specific
44
# commercial products, process, or services by trade name, trademark,
45
# manufacturer or otherwise does not necessarily constitute or imply its
46
# endorsement, recommendation, or favoring by the United States
47
# Government or Lawrence Livermore National Security, LLC. The views and
48
# opinions of authors expressed herein do not necessarily state or
49
# reflect those of the United States Government or Lawrence Livermore
50
# National Security, LLC, and shall not be used for advertising or
51
# product endorsement purposes.
53
# ----------------------------------------------------------------------------
54
# Purpose: Difference two silo files and/or directories containing silo files
56
# Programmer: Mark C. Miller
57
# Creation: January 21, 2009
60
# Mark C. Miller, Wed Mar 11 10:03:10 PDT 2009
61
# Added browserOptsDef and set lowlevel to 0. That is important when
62
# diff'ing HDF5 files.
64
# Mark C. Miller, Wed Dec 2 11:47:31 PST 2009
65
# Added logic to use path to browser that is 'next to' silodiff or fall
66
# back what a browser in path, but issue a warning if they are somehow
69
# Mark C. Miller, Fri Dec 4 09:58:17 PST 2009
70
# Made it possible to override browser path warning
71
# ----------------------------------------------------------------------------
75
# Handle Command Line Arguments
78
if test -z "$tmpDir"; then
79
if test -d /usr/tmp; then
81
elif test -d /tmp; then
84
tmpDir=`(cd ~; pwd -P)`
88
browserOptsDef="-l 0 -r"
99
# handle empty argument
113
-override-browser-warning|--override-browser-warning)
119
if test -z "$arg1"; then
125
browserOpts="$browserOpts $1"
133
# Check path to browser and issue error/warning if necessary
137
if test -x ${sddir}/browser; then
138
brexe=${sddir}/browser
140
brdir=$(dirname $(which browser))
141
if test $brdir != $sddir; then
143
if test $override -eq 0; then
147
echo "$leader Using browser at \"$brdir\"."
148
echo "$leader and silodiff at \"$sddir\"."
150
if test $override -eq 0; then
151
echo "$leader Override with \"--override-browser-warning\" option."
157
if test $optError = 1 -o -z "$arg1" -o -z "$arg2"; then
158
echo "Usage: $0 <file|dir> <file|dir> <options>"
161
echo " -help: print this help message"
162
echo " -recurse: recurse on directories"
163
echo " -verbose: report names of file(s) as they are processed."
165
echo "If both arguments are files, $0 will attempt to diff the files."
167
echo "If one argument is a file and the other a directory, then $0 will attempt"
168
echo "to diff the given file with a file by the same name in the given directory."
170
echo "If both arguments are directories, $0 will descend into each directory"
171
echo "(and will do so recursively if '-recurse' is specified) finding files"
172
echo "whose names differ ONLY in the first component of their paths and attempt"
175
echo "$0 uses Silo's browser tool to do its work. In turn, browser supports a"
176
echo "number of additional options. Thus, any arguments to $0 which are neither"
177
echo "files nor directories are treated as arguments to browser itself. For some"
178
echo "options to browser like the '-f FILE' option, use the '--file=<FILE>'"
179
echo "variant instead. By default, $0 will invoke browser with args"
180
echo "'$browserOptsDef'. The available options to browser are..."
182
$brexe --help 2>&1 | grep -v SWITCHES
186
if test -d $arg1 -a -d $arg2; then # both are dirs
189
df=`echo $f | rev | cut -d'/' -f1 | rev`
190
if test $recurse = 1; then
191
if test -d $arg2/$df; then
192
if test $verbose = 1; then
193
echo "Processing directory \"$df\"..."
194
$0 -recurse -verbose $browserOpts $f $arg2/$df
196
$0 -recurse $browserOpts $f $arg2/$df
199
test $verbose = 1 && echo "Directory \"$df\" does not exist in \"$arg2\", skipping it."
202
test $verbose = 1 && echo "\"$df\" is a directory, skipping it. Use -recurse to process directories."
206
if test -e $arg2/$bf; then
207
test $verbose = 1 && echo "Processing file \"$bf\"..."
208
$brexe $browserOptsDef $browserOpts -e diff $f $arg2/$bf
210
test $verbose = 1 && echo "File \"$bf\" does not exist in \"$arg2\", skipping it."
214
elif test -d $arg1 -o -d $arg2; then # one is dir
215
if test -d $arg1; then
216
$brexe $browserOptsDef $browserOpts -e diff $arg1/$arg2 $arg2
218
$brexe $browserOptsDef $browserOpts -e diff $arg1 $arg2/$arg1
220
else # neither are dirs
221
$brexe $browserOptsDef $browserOpts -e diff $arg1 $arg2