summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorTommy Reynolds <Tommy.Reynolds@MegaCoder.com>2006-01-17 02:02:13 +0000
committerTommy Reynolds <Tommy.Reynolds@MegaCoder.com>2006-01-17 02:02:13 +0000
commit5701df1e25af2fca1d46fb357404bed36013085c (patch)
tree4d04be7d6c230f6cfbe72eb13ed7100d066d57a0 /bin
parent37c0cf62317836bb0d317bc63f3720f465648c2f (diff)
downloadfedora-doc-utils-5701df1e25af2fca1d46fb357404bed36013085c.tar.gz
fedora-doc-utils-5701df1e25af2fca1d46fb357404bed36013085c.tar.xz
fedora-doc-utils-5701df1e25af2fca1d46fb357404bed36013085c.zip
Conditionally move source file to target if, and only if, their
content differs. This can help avoid unnecessary rebuilds when working with derived files.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/move-if-change32
1 files changed, 32 insertions, 0 deletions
diff --git a/bin/move-if-change b/bin/move-if-change
new file mode 100755
index 0000000..ee1b348
--- /dev/null
+++ b/bin/move-if-change
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+# Copyright (C) 1996 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is 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, write to the Free Software
+# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+if
+test -r $2
+then
+if
+cmp $1 $2 > /dev/null
+then
+echo $2 is unchanged
+rm -f $1
+else
+mv -f $1 $2
+fi
+else
+mv -f $1 $2
+fi