diff --git a/TODO.txt b/TODO.txt index 37daa0e..efb83e8 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,14 +1,19 @@ -- Add environment variable to override defaults -- Make serial number postfix consistent across dirs and files - Add -h help and usage screen Doc Notes --------- +- Note that symlinks are not expanded but that targets + accessed via symlinks are stored to canonical path. + - Test mode has no effect on -d which always works + - If -d is effective immediately upon reading command line so you can clean multiple graveyards with: /trm.sh -g ./foo -d -g ./baz -d - Note difference between -vd and -dv + +- Note differences between how serial numbers are appended + on directories vs. files. Use of find to overcome this. diff --git a/trm.sh b/trm.sh index e89741a..c5611f5 100755 --- a/trm.sh +++ b/trm.sh @@ -5,7 +5,8 @@ # Permission granted for the free use of this program without restriction GRAVEYARD="${HOME}/.graveyard" -TESTING="Running in test mode ..." +INTERPROMPT="Do You Want To Remove(Copy):" +TESTING="Test Mode ..." mkdir -p $GRAVEYARD @@ -17,10 +18,13 @@ # Parse command line args - OPERATOR="mv" # Can be overriden with -c option - OPTLIST='cdg:stvx' # List of all legal command line options - OPTIND=1 # getopts may have been previously used in this context + OPTLIST='cdg:istvx' # List of all legal command line options + OPTIND=1 # in case getopts was previously used in this context + # Defaults + + INTERACTIVE="" + OPERATOR="mv" # Can be overriden with -c option SERIALNO="Yes" # Generate serial numbers TESTMODE="" VERBOSE="" @@ -45,6 +49,10 @@ GRAVEYARD=${OPTARG} ;; + i) + INTERACTIVE="Yes" + ;; + # Turn of serial number generation s) SERIALNO="" @@ -72,6 +80,9 @@ esac done + # Notify if in test mode + echo ${TESTMODE} + # Process arguments shift $((OPTIND-1)) @@ -116,9 +127,23 @@ CMD="${OPERATOR} $VERBOSE '${REALPATH}' '${DESDIR}/${DESFIL}'" if [ -n "${TESTMODE}" ] then - echo ${TESTMODE} echo ${CMD} else + + # Handle interactive requests + if [ -n "${INTERACTIVE}" ] + then + echo -n "${INTERPROMPT} ${REALPATH}? " + read doit + + if [ "${doit}" != "y" ] && [ "${doit}" != "Y" ] + then + shift + continue + fi + + fi + mkdir -p "${DESDIR}" eval ${CMD} fi @@ -131,4 +156,4 @@ # Uncomment to invoke as a free standing utility -# trm "$@" +trm "$@"