Changes to work on systems with older versions of mv and mktemp such

as CentOS 5.

Fix issue where file name included extension twice.
This commit is contained in:
Robert Rothenberg 2011-11-05 16:38:10 +00:00
parent 1795ec5114
commit cd1e34565d

9
trash
View File

@ -233,10 +233,11 @@ function trash_file {
ext="" ext=""
fi fi
# Use --dry-run option because we cannot mv a directory into a file. # Use -u (unsafe) option because we cannot mv a directory into a
# This is technically "unsafe" but we use --no-clobber option in mv. # file. This is technically "unsafe" but mv will ask for
# confirmation when overwriting.
deletedfile=$(mktemp --dry-run --tmpdir="${trashdir}/files" --suffix="${ext}" "${trashname}_XXXXXXXX" ) deletedfile=$(mktemp -u "${trashdir}/files/${origname}_XXXXXXXX" )$ext
deletedbase=$( basename "${deletedfile}" ) deletedbase=$( basename "${deletedfile}" )
deletedinfo="$trashdir/info/${deletedbase}.trashinfo" deletedinfo="$trashdir/info/${deletedbase}.trashinfo"
@ -252,7 +253,7 @@ END
# permissions of the person who deleted the file, and not # permissions of the person who deleted the file, and not
# necessarily of the original file. # necessarily of the original file.
mv $mv_opts --no-clobber "${filename}" "${deletedfile}" mv $mv_opts "${filename}" "${deletedfile}"
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo "${progname}: unable to move ${filename} to ${deletedfile}" 1>&2 echo "${progname}: unable to move ${filename} to ${deletedfile}" 1>&2
rm "$deletedinfo" rm "$deletedinfo"