#!/bin/sh

set -e
set -x

TESTDIR=/tmp/rsync.bug.$$
RSYNCCOMMAND="rsync -ar --delete-after source/ dest/"

mkdir "${TESTDIR}"
cd "${TESTDIR}"

mkdir source dest

# Create a source directory with something to rsync
mkdir source/somedir
date > source/somedir/thing1

# rsync it
$RSYNCCOMMAND

# Change somedir to a symlink
mv source/somedir source/otherdir
ln -s otherdir source/somedir

# rsync it again
$RSYNCCOMMAND

# clean up directory
rm -rf "${TESTDIR}"

# EOF

