Imported Upstream version 1.10.2
[platform/upstream/krb5.git] / src / config / move-if-changed
1 #!/bin/sh
2 # Move file 1 to file 2 if they don't already match.
3 # Good for "make depend" for example, where it'd be nice to keep the
4 # old datestamp.
5 if [ $# != 2 ]; then
6   echo 2>&1 usage: $0 newfile oldfilename
7   exit 1
8 fi
9 #
10 if [ ! -r "$2" ]; then
11   exec mv -f "$1" "$2"
12 fi
13 if cmp "$1" "$2" >/dev/null; then
14   echo "$2 is unchanged"
15   exec rm -f "$1"
16 fi
17 exec mv -f "$1" "$2"