diff --git a/trm.sh b/trm.sh index b5a64ee..8b91763 100755 --- a/trm.sh +++ b/trm.sh @@ -10,24 +10,47 @@ mkdir -p $GRAVEYARD + +##### +# Display usage information +##### + +trm_usage() +{ + echo "usage: trm.sh -cehistvx -g graveyard [file|dir] ..." + echo " where," + echo " -c copy targets to graveyard, don't remove them" + echo " -e empty the current graveyard (permanent removal" + echo " -h display this help screen" + echo " -g graveyard use named graveyard instead of default" + echo " -i interactive removal/copy" + 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" + +} + + +##### # This function is called at the bottom of this file or it can # be embedded in a shell startup script. +##### trm() { # Parse command line args - OPTLIST='cdg:istvx' # List of all legal command line options - OPTIND=1 # in case getopts was previously used in this context + OPTLIST='ceg:histvx' # 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 + OPERATOR="mv" # Can be overriden with -c option + SERIALNO="Yes" # Generate serial numbers TESTMODE="" - USAGE="" VERBOSE="" while getopts ${OPTLIST} opt @@ -41,7 +64,7 @@ ;; # Empty the graveyard - d) + e) rm -rf ${VERBOSE} ${GRAVEYARD}/* ${GRAVEYARD}/.[-z]* ;; @@ -50,6 +73,11 @@ GRAVEYARD=${OPTARG} ;; + h) + trm_usage + return 0 + ;; + i) INTERACTIVE="Yes" ;; @@ -75,8 +103,8 @@ ;; *) - USAGE="Yes" - exit 1 + trm_usage + return 1 ;; esac done