#!/bin/sh

set -e
if [ $1 = "-t" ] ; then
    shift
fi
if [ ! "$2" ] ; then
    echo >&2 "Usage: $0 <sourcedir> <targetdir>"
    exit 1
fi
if [ -d "$1" ] ; then
    dir="$1"
else
    dir=`dirname "$1"`
fi
while [ "$2" ] ; do
    shift
done
dest=`echo "$1" | sed s,/*$,,`
if [ -d "$dest" ] ; then
    dest="$dest/`basename $dir`"
fi
mkdir -p "$dest"
tar Ccf $dir - . | tar Cxf $dest -

# Local variables:
#   indent-tabs-mode: nil
# End:
#
# vim: expandtab shiftwidth=4:
