#!/bin/sh
# copyexamples dir  : copies examples under dir
#
# We use tar instead of cp -r because some brain-damaged machines don't
# have cp -r.
#------------------------------------------------------------
prog=`basename $0`
srcdir=`dirname $0`
#
if [ $# -ne 1 ]
then echo "Usage: $prog dir : Copies examples under dir (dir must exist)."
     exit 0
fi
#
destdir=$1

if [ ! -d $destdir ]; then
  echo "*** ERROR *** Directory $destdir doesn't exist. Aborted."
  exit 1
fi
#

#
cd $srcdir
echo "Copying examples ..."
cp -r . $destdir

#-- tar has problems if directories are 555
#tar cf - . | ( cd $destdir; tar xf -)

#
# now open the permissions
#

echo "Setting/opening permissions in target directory ..."
cd $destdir
find . -type f -exec chmod 666 {} \;
find . -type d -exec chmod 755 {} 2>&1 > /dev/null \;

echo done.
