#! /bin/sh
USAGE="Usage: $0 fromdir [todir]"
if [ $then
echo "$USAGE"
exit 1
fi
DIRFROM=$1
if [ $then
DIRTO=$2
else
DIRTO=.
fi
if [ ! -d $DIRTO ]
then
echo "$0: $DIRTO is not a directory"
echo "$USAGE"
exit 2
fi
cd $DIRTO
if [ ! -d $DIRFROM ]
then
echo "$0: $DIRFROM is not a directory"
echo "$USAGE"
exit 2
fi
pwd=`pwd`
if [ `(cd $DIRFROM; pwd)` = $pwd ]
then
echo "$pwd: FROM and TO are identical!"
exit 1
fi
for file in `ls -af $DIRFROM`
do
if [ ! -d $DIRFROM/$file ]
then
ln -s $DIRFROM/$file .
else
if [ $file != RCS -a $file != .svn -a $file != . -a $file != .. ]
then
echo $file:
mkdir $file
(cd $file
pwd=`pwd`
case "$DIRFROM" in
/*) ;;
*) DIRFROM=../$DIRFROM ;;
esac
if [ `(cd $DIRFROM/$file; pwd)` = $pwd ]
then
echo "$pwd: FROM and TO are identical!"
exit 1
fi
$0 $DIRFROM/$file
)
fi
fi
done