#!/bin/bash -f

#  Remove the object file FILE from the directory FILEDIR if FILE is present

#  syntax rmobfile rm-command file-dir file-name ,

#  where rm-command   is the appropriate "rm" command,
#        file-dir     is the name of the directory from which the
#                     file to be removed
#        file-name    is the name of the file to be removed

#  Nick Gould, for GALAHAD production
#  This version: 2023-01-26

f=$#
let d=f-1
let a=d-1

RM="${*:1:a}"
FILEDIR="${!d}"
FILE="${!f}"

#[[ -e ${FILEDIR}/${FILE} ]] && echo -n -e "\n      removing ${FILE}"
[[ -e ${FILEDIR}/${FILE} ]] && $RM ${FILEDIR}/${FILE}

exit 0
