#!/bin/sh
#
#NAME
#  cptree - copy directory tree via cpio
#
#SYNOPSIS
#  cptree olddir newdir
#
#DESCRIPTIONo
#  Copy the contents of olddir to newdir, making newdir if necessary.
#
#  The copy is done by cpio; we just set up its parameters and to the
#  necessary cd's. The main point in putting this into a script is so
#  that we can use the natural syntax and  have  it  work  correctly.
#  This  can  be done with "cp -r" on most Unix-like systems, but the
#  syntax is counterintuitive and  often  takes  many  tries  to  get
#  right.  This script does it the obvious way.
#
#AUTHOR
# John Chambers <jc@trillian.mit.edu>

if [ $# != 2 ];then echo Usage: $0 olddir newdir; exit 1; fi
case $1 in
	/*) src=$1;;
	 *) src=`pwd`/$1;;
esac
case $2 in
	/*) dst=$2;;
	 *) dst=`pwd`/$2;;
esac
test -d $src || { echo No directory $src; exit 1; }
test -d $dst || mkdir -p $dst
test -d $dst || { echo No directory $dst; exit 1; }
cd $src
find . -print | cpio -pdum $dst
