#ident	"@(#)r.sed	1.4	02/09/23 SMI"	/* SVr4.0  1.6	*/ 

error=no
while read dest
do
	if [ -d $dest ]
	then
		echo "$dest"
		rmdir $dest || error=yes
	elif [ -f $dest ]
	then
		echo "Modifying $dest"
		
		# Strip PKG_INSTALL_ROOT from dest if installation is to an
		# alternate root.

		if [ -n "$PKG_INSTALL_ROOT" -a "$PKG_INSTALL_ROOT" != "/" ]; then
			client_dest=`echo $dest | \
				/usr/bin/nawk -v rootdir="$PKG_INSTALL_ROOT" '{
				    { print substr($0, length(rootdir)+1)} }'`
			savepath=$PKGSAV/sed${client_dest}
		else
			savepath=$PKGSAV/sed${dest}
		fi
		/usr/sadm/install/scripts/cmdexec /bin/sed remove $savepath $dest ||
			error=yes
	else
		[ -r $dest ] && echo "$dest"
		rm -f $dest || error=yes
	fi
done
[ "$error" = yes ] &&
	exit 2
exit 0
