This commit is contained in:
Roy Marples 2009-02-23 09:35:57 +00:00
parent 70d8c5beda
commit 749938d439

View File

@ -14,13 +14,16 @@ TMPDIR=tmp-"$(basename "$0")"
# the reference file # the reference file
# #
# EXAMPLE: if is_older_than a.out *.o ; then ... # EXAMPLE: if is_older_than a.out *.o ; then ...
ref_is_older_than() { ref_is_older_than()
{
local x= ref="$1" local x= ref="$1"
shift shift
for x; do for x; do
[ "${x}" -nt "${ref}" ] && return 0 [ "${x}" -nt "${ref}" ] && return 0
[ -d "${x}" ] && ref_is_older_than "${ref}" "${x}"/* && return 0 if [ -d "${x}" ]; then
ref_is_older_than "${ref}" "${x}"/* && return 0
fi
done done
return 1 return 1
} }
@ -28,7 +31,8 @@ ref_is_older_than() {
rm -rf "${TMPDIR}" rm -rf "${TMPDIR}"
mkdir "${TMPDIR}" mkdir "${TMPDIR}"
do_test() { do_test()
{
local r1= r2= local r1= r2=
ref_is_older_than "$@" ref_is_older_than "$@"
@ -40,13 +44,15 @@ do_test() {
[ $r1 = $r2 ] [ $r1 = $r2 ]
} }
echo_cmd() { echo_cmd()
{
[ -n "${VERBOSE}" ] && echo "$@" [ -n "${VERBOSE}" ] && echo "$@"
"$@" "$@"
} }
test_it() { test_it()
do_test "${TMPDIR}"/ref "${TMPDIR}"/dir1 "${TMPDIR}"/dir2 || exit 1 {
do_test "${TMPDIR}"/ref "${TMPDIR}"/dir1 "${TMPDIR}"/dir2
} }
echo_cmd mkdir -p "${TMPDIR}"/dir1 "${TMPDIR}"/dir2 echo_cmd mkdir -p "${TMPDIR}"/dir1 "${TMPDIR}"/dir2