#!/bin/sh
# my -- break links to given files
#
# SYNOPSIS:  For each file argument, make a copy of the given file
# with no links to it.
#
# AUTHOR:	Gary T. Leavens

[ -n "$echo" ] && set -x


USAGE="Usage: $0 file ..."

if test $# -eq 0
then
	echo "$USAGE" >&2
	exit 2
fi

# temp file
TMP=/usr/tmp/my.$$

# turn off interrupts
trap '' 1 2 3 15 

for f 
do
	test -r $f ||
	{
		echo "my: ERROR: cannot read $f" >&2
		exit 1
	}
	
	cp $f $TMP &&
	rm -f $f &&
	mv $TMP $f ||
	{
		echo "my: ERROR: failed to break links to $f" >&2
		exit 1
	}
done

exit 0
