diff options
author | dos-reis <gdr@axiomatics.org> | 2007-08-14 05:14:52 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2007-08-14 05:14:52 +0000 |
commit | ab8cc85adde879fb963c94d15675783f2cf4b183 (patch) | |
tree | c202482327f474583b750b2c45dedfc4e4312b1d /config/move-if-change | |
download | open-axiom-ab8cc85adde879fb963c94d15675783f2cf4b183.tar.gz |
Initial population.
Diffstat (limited to 'config/move-if-change')
-rwxr-xr-x | config/move-if-change | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/config/move-if-change b/config/move-if-change new file mode 100755 index 00000000..ff74a556 --- /dev/null +++ b/config/move-if-change @@ -0,0 +1,22 @@ +#!/bin/sh +# Like mv $1 $2, but if the files are the same, just delete $1. +# Status is zero if successful, nonzero otherwise. + +usage="$0: usage: $0 SOURCE DEST" + +case $# in +2) ;; +*) echo "$usage" >&2; exit 1;; +esac + +for arg in "$1" "$2"; do + case $arg in + -*) echo "$usage" >&2; exit 1;; + esac +done + +if test -r "$2" && cmp -s "$1" "$2"; then + rm -f "$1" +else + mv -f "$1" "$2" +fi |