XcodeToolkit/Colorsets/cp_if_different.sh

27 lines
904 B
Bash
Executable file

#!/bin/zsh
#======================================================================================
# FILE: cp_if_different.sh
#
# USAGE: cp_if_different.sh source_file target_file
#
# DESCRIPTION: Copies the contents of the source_file to the target_file
# if target_file content is different then source_file content.
# Useful for copying autogenerated Swift files to avoid
# recompilations due to changes of file's modification date.
#======================================================================================
SOURCE_LOCATION=$1
DESTINATION_LOCATION=$2
if test -f $DESTINATION_LOCATION; then
if cmp --silent $SOURCE_LOCATION $DESTINATION_LOCATION; then
# files are identical
exit 0
else
# files are different
rm $DESTINATION_LOCATION
fi
fi
cp $SOURCE_LOCATION $DESTINATION_LOCATION