diff --git a/trm.sh b/trm.sh index bde721d..3ad00e9 100755 --- a/trm.sh +++ b/trm.sh @@ -7,6 +7,7 @@ COPYRIGHT='2016' GITID='1ca95bc tundra Fri Oct 28 09:27:57 2016 -0500' VERSION='1.102' +OLDIFS=${IFS} # Preserve IFS for later use in protecting files/dirs with spaces in their name GRAVEYARD="${HOME}/.graveyard" INTERPROMPT="Do You Want To Remove(Copy):" @@ -152,7 +153,7 @@ # Bare symlink itelf - REALPATH=$(readlink -f $(dirname -- "$1")) + REALPATH=$(readlink -f -- $(dirname -- "$1")) if [ "${REALPATH}" = '/' ] then REALPATH="" @@ -163,7 +164,7 @@ # Process normal files and directories else - REALPATH=$(readlink -f "$1") + REALPATH=$(readlink -f -- "$1") fi # See if we want serial numbers @@ -185,7 +186,12 @@ SRCFIL=$(basename -- "${REALPATH}") DESDIR="${GRAVEYARD}${SRCDIR}" DESFIL="${SRCFIL}${SERIAL}" - CMD="${OPERATOR} $VERBOSE '${REALPATH}' '${DESDIR}/${DESFIL}'" + + # Temporarily assign field separator to a character never used in + # a filename. Needed to preserve spaces in file/dirnames + + IFS='>' + CMD="${OPERATOR} $VERBOSE -- '${REALPATH}' '${DESDIR}/${DESFIL}'" # If we're in test mode, just show what we would do @@ -219,6 +225,7 @@ fi shift + IFS=${OLDIFS} done