| |
---|
| | echo " -s don't generate serial number suffixes" |
---|
| | echo " -t test mode, just show what would be done" |
---|
| | echo " -v verbose mode - noisy output" |
---|
| | echo " -x execute, overrides previous -t" |
---|
| | |
---|
| | } |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| |
---|
| | esac |
---|
| | done |
---|
| | |
---|
| | # Notify if in test mode |
---|
| | echo ${TESTMODE} |
---|
| | |
---|
| | if [ -n "${TESTMODE}" ] |
---|
| | then |
---|
| | echo ${TESTMODE} |
---|
| | fi |
---|
| | |
---|
| | # Process arguments |
---|
| | |
---|
| | shift $((OPTIND-1)) |
---|
| | while [ $# -gt 0 ] |
---|
| | do |
---|
| | |
---|
| | # Symlinks require special care |
---|
| | |
---|
| | if [ -L "$1" ] |
---|
| | then |
---|
| | |
---|
| | # Bare symlink itelf |
---|
| | |
---|
| | REALPATH=$(readlink -f $(dirname "$1")) |
---|
| | if [ "${REALPATH}" = '/' ] |
---|
| | then |
---|
| | REALPATH="" |
---|
| |
---|
| | |
---|
| | REALPATH="${REALPATH}"/$(basename "$1") |
---|
| | |
---|
| | # Process normal files and directories |
---|
| | |
---|
| | else |
---|
| | REALPATH=$(readlink -f "$1") |
---|
| | fi |
---|
| | |
---|
| | # See if we want serial numbers |
---|
| | |
---|
| | SERIAL="" |
---|
| | if [ -n "${SERIALNO}" ] |
---|
| | then |
---|
| | SERIAL=".$(date +%Y%m%d%H%M%S)" |
---|
| | fi |
---|
| | |
---|
| | # Figure out absolute paths for source and destination |
---|
| | |
---|
| | SRCDIR=$(dirname "${REALPATH}") |
---|
| | if [ "${SRCDIR}" = '/' ] |
---|
| | then |
---|
| |
---|
| | |
---|
| | SRCFIL=$(basename "${REALPATH}") |
---|
| | DESDIR="${GRAVEYARD}${SRCDIR}" |
---|
| | DESFIL="${SRCFIL}${SERIAL}" |
---|
| | |
---|
| | CMD="${OPERATOR} $VERBOSE '${REALPATH}' '${DESDIR}/${DESFIL}'" |
---|
| | |
---|
| | # If we're in test mode, just show what we would do |
---|
| | |
---|
| | if [ -n "${TESTMODE}" ] |
---|
| | then |
---|
| | echo ${CMD} |
---|
| | |
---|
| | # We're really doing this |
---|
| | |
---|
| | else |
---|
| | |
---|
| | # Handle interactive requests |
---|
| | |
---|
| | if [ -n "${INTERACTIVE}" ] |
---|
| | then |
---|
| | echo -n "${INTERPROMPT} ${REALPATH}? " |
---|
| | read doit |
---|
| |
---|
| | fi |
---|
| | |
---|
| | fi |
---|
| | |
---|
| | # Make sure the destination directory exists and do the work |
---|
| | |
---|
| | mkdir -p "${DESDIR}" |
---|
| | eval ${CMD} |
---|
| | fi |
---|
| | |
---|
| |
---|
| | |
---|
| | } |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Run now if invoked directly on the command line. (Otherwise, we're |
---|
| | # just loading the function above into the current shell context.) |
---|
| | ##### |
---|
| | |
---|
| | if [ $(basename "$0") = "trm.sh" ] |
---|
| | then |
---|
| | trm "$@" |
---|
| | |