chiark / gitweb /
fishdescriptor: wip reconsider approach
[chiark-utils.git] / scripts / cvs-adjustroot
index 5418f1cbe0e5b2fb945eb06bd329f3257c4d389a..080029c7320a7b549b137e1a4eab1aec682a828a 100755 (executable)
@@ -13,15 +13,41 @@ case "$#.$1" in
 *)             usage                   ;;
 esac
 
+# Copyright 2004 Ian Jackson <ian@chiark.greenend.org.uk>
+#
+# This script and its documentation (if any) are free software; you
+# can redistribute it and/or modify them under the terms of the GNU
+# General Public License as published by the Free Software Foundation;
+# either version 3, or (at your option) any later version.
+# 
+# chiark-named-conf and its manpage are distributed in the hope that
+# it will be useful, but WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE.  See the GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, consult the Free Software Foundation's
+# website at www.fsf.org, or the GNU Project website at www.gnu.org.
+
+
 old="$1"; shift
 new="$1"; shift
 
 if $reinvoke; then
        filename="$1";
+       if cmp -- "$filename" <(printf "%s\n" "$new"); then exit 0; fi
        cmp -- "$filename" <(printf "%s\n" "$old")
        printf "%s\n" "$new" >"$filename".new
        mv -f -- "$filename".new "$filename"
        exit 0
 fi
 
-find -path '*/CVS/Root' -exec cvs-adjustroot --reinvoke "$old" "$new" '{}' ';'
+# GNU find provides + exec variants which set exit status and pass
+# multiple arguments, or \; variants which pass one argument but do
+# not set exit status.  So use a separate -exec false + to arrange for
+# nonzero exit status when appropriate.
+
+find   -path '*/CVS/Root'                                              \
+  \(   -exec "$0" --reinvoke "$old" "$new" '{}' ';'                    \
+  -o   -exec false '{}' +                                              \
+  \)