#!/bin/csh
if !(-d $1) then
	echo $1 is not a directory
	exit 1
else if ((-e ${1}.tar) || (-e ${1}.tar.gz)) then
	echo Tar file already exists in superior for $1
	exit 2
endif
set GZIP = `which gzip`
if ($#GZIP != 1) then
	echo Where is gzip\?
	exit 3
endif
alias checkstatus '\!* ; if ($status) exec echo "\!*" failed - status = $status'
checkstatus du -s $1
checkstatus cd $1
checkstatus tar -clf ../${1}.tar .
checkstatus gzip ../${1}.tar
#checkstatus rm -rf * .* >& /dev/null
# avoid files like "-Pcore3" ;^(
checkstatus rm -rf ./* ./.* >& /dev/null
checkstatus mv ../${1}.tar.gz .
checkstatus cd ..
checkstatus du -s $1
