#!/bin/sh
#
#	Make a gzip'd tar'd archive $1 (or stdout) out of specified files (or .).
#
# 94.02.19 DCN	Created

Error ()
{	echo "Error: $0: ${@-}!" >&2
	exit 1
}

if [ $# = 0 ]; then
	dest=
	src=.
	tar cvf - . | gzip -9v
	exit 0
elif [ $# = 1 ]; then
	dest=$1
	src=.
else
	dest=$1
	shift
	src="${@-}"
fi

if [ -h "$dest" ]; then
	Error "Destination file \"$dest\" already exists as a symbolic link"
elif [ -f "$dest" ]; then
	Error "Destination \"$dest\" already exists as a file"
elif [ -d "$dest" ]; then
	Error "Destination \"$dest\" already exists as a directory"
fi
if [ -z "$dest" -o "X$dest" = 'X-' ]; then
	tar cvf - $src | gzip -9v
else
	tar cvf - $src | gzip -9v > $dest
fi
