#!/bin/sh
# 
# uninstall -- uninstall files/directories
# 
# Author: Ian.Piumarta@INRIA.Fr
# 
# Last edited: 2002-06-06 05:12:25 by piumarta on emilia.inria.fr

test=`which test`

if test $# -lt 1; then
  echo "usage: $0 dir files..."
fi

dir=$1
shift

if test -d ${dir}; then
  for file in $*; do
    if $test -f "${dir}/${file}" -o -L "${dir}/${file}"; then
      echo "rm -f ${dir}/${file}"
      rm -f ${dir}/${file}
    fi
  done
fi

while test "${dir}" != "/" -a "${dir}" != "."; do
  if test -d ${dir}; then
    test "`echo ${dir}/*`" != "${dir}/*" && break;
    echo "rmdir ${dir}"
    rmdir ${dir}
  fi
  dir=`dirname ${dir}`
done
