From 50cb5923c7363e3ec514713ce41df82468f37365 Mon Sep 17 00:00:00 2001 From: Robert Rothenberg Date: Sat, 18 Jun 2011 13:26:37 +0100 Subject: [PATCH] Uses mktemp to generate unique name in trashcan directory --- trash | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/trash b/trash index e9b883e..202d08f 100755 --- a/trash +++ b/trash @@ -15,7 +15,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -version="0.3.8 \$Id: trash 2011/06/18 13:04:58 BST rr@newfie $" +version="0.3.9 \$Id: trash 2011/06/18 13:24:35 BST rr@newfie $" progname=`basename $0` @@ -233,15 +233,9 @@ function trash_file { ext="" fi - cnt=1 - while [ -e "$trashdir/files/$trashname" ] || \ - [ -e "$trashdir/info/$trashname.trashinfo" ]; do - trashname="${origname}_${cnt}${ext}" - let cnt=cnt+1 - done - - deletedfile="$trashdir/files/$trashname" - deletedinfo="$trashdir/info/$trashname.trashinfo" + deletedfile=$(mktemp --tmpdir="${trashdir}/files" --suffix="${ext}" "${trashname}_XXXXXXXX" ) + deletedbase=$( basename "${deletedfile}" ) + deletedinfo="$trashdir/info/${deletedbase}.trashinfo" canon=`url_encode "$filename"`