#!/bin/sh

# determine the installation directory of stic_std_variables and execute inline
if test -n "$STIC_MAIN_DIR"
then
  stic_init_dir=$STIC_MAIN_DIR
elif test -r $HOME/.stic_main_dir
then
  stic_init_dir=$(cat $HOME/.stic_main_dir)
fi
if test "$stic_init_dir" = ""
then
  stic_init_dir=$(dirname "$0")/
else
  stic_init_dir="$stic_init_dir"/scripts/
fi
if test -r "$stic_init_dir"stic_std_variables
then
  . "$stic_init_dir"stic_std_variables
elif test  -z "$STIC_NO_BASH" -a -n "$(type -p stic_std_variables)"
then
  . stic_std_variables
fi

map_cmd=""

for i in "$@" 
do
  if test -f "$i"
  then
    echo "file $i : remove from disk and database ?"
    read antw
    if test "$antw" = "Y" -o "$antw" = "y" -o "$antw" = "J" -o "$antw" = "j"
    then
      if test -e $(dirname "$i")/.imv_guarded_directory
      then
        "$stic_bin_dir"similar $map_cmd -del_file:"$i"
      fi
      if rm "$i"
      then
        echo >/dev/null
      else
        if test -e $(dirname "$i")/.imv_guarded_directory
        then
          "$stic_bin_dir"similar $map_cmd -append:"$i"
        fi
      fi
    else
      echo "ommitted : $i"
    fi
  else
    echo "not found : $i"
  fi
done

