#!/bin/sh
#
# Mach Operating System
# Copyright (c) 1994 Johannes Helander
# All Rights Reserved.
# 
# Permission to use, copy, modify and distribute this software and its
# documentation is hereby granted, provided that both the copyright
# notice and this permission notice appear in all copies of the
# software, derivative works or modified versions, and any portions
# thereof, and that both notices appear in supporting documentation.
# 
# JOHANNES HELANDER ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
# CONDITION.  JOHANNES HELANDER DISCLAIMS ANY LIABILITY OF ANY KIND
# FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
#
#
# HISTORY
# $Log: $
#
# Like mv but doesn't affect the tofile modification time if there is
# no change in contents.  If the files differ then diff output is printed.
#

if [ $# != 2 ]; then
	echo Usage: move-if-change fromfile tofile
	exit 1
fi

if [ -r $2 ] && diff $1 $2 ; then
	[ "X$1" = "X$2" ] || rm -f $1
	exit 0
fi

rm -f $2
mv $1 $2
exit $?
