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

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/awk${client_dest}
		else
			savepath=$PKGSAV/awk${dest}
		fi

		/usr/sadm/install/scripts/cmdexec /usr/bin/awk remove $savepath $dest ||
			error=yes
	else
		[ -r $dest ] && echo "$dest"
		rm -f $dest || error=yes
	fi
done
[ "$error" = yes ] &&
	exit 2
exit 0
