#!/bin/csh -f

echo 'This is experimental. Eventually, you should preferably use '
echo 'rcssetvname (it has a recusive option).'
set rep=n
while ( "$rep" != "y" )
	echo -n 'Do you still want to use this tool (y/n) ?'
	set rep="$<"
end

if ( $#argv < 2 ) then
	if ( $#argv < 1 ) then
		set pname=`basename $0`
		echo ${pname} usage:
		echo "	${pname} version_name source_file..."
		exit 1
	else if ( "$1" == "print" ) then
		rlog RCS/* \
		| grep 'symbolic names:' \
		| sed -e 's/symbolic names://' \
		| tr ';' '\012' \
		| sed -e 's/:.*//' -e 's/^ *//' \
		| sort -u
	else
		set pname=`basename $0`
		echo ${pname} usage:
		echo "	${pname} print | version_name source_file..."
		exit 1
	endif
endif

set vname=$1
shift

set rcscmds=/tmp/rcsname.$$

foreach f ( $* )
	set version=`rlog $f | grep head: | sed -e 's/head: *//'`
	rcs -n${vname}:$version $f
end
exit 0

( ident $* \
	| grep '$Id: ' \
	| sed -e 's/.*\$Id: \(.*\),v \([0-9.]*\) .*/rcs -n'${vname}':\2 \1/' \
	> $rcscmds \
) >& /dev/null \
&& source $rcscmds
cat $rcscmds
rm $rcscmds

#end



