From f1efef4a1f2654556658e868bdbb6960b60bfd06 Mon Sep 17 00:00:00 2001
From: Robert Rothenberg <rob@fastmail.net>
Date: Wed, 22 Jun 2011 07:28:55 +0100
Subject: [PATCH] When mv fails, prints an error and removes the .trashinfo
 file.

Added comment about permissions/ownership of .trashinfo file.
---
 trash | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/trash b/trash
index c2afcc1..1f6dac9 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.10 \$Id: trash 2011/06/22 07:10:41 BST rr@newfie $"
+version="0.3.11 \$Id: trash 2011/06/22 07:23:55 BST rr@newfie $"
 
 progname=`basename $0`
 
@@ -248,7 +248,16 @@ Path=$canon
 DeletionDate=`date +"%FT%H:%M:%S"`
 END
 
+  # Note that the trashinfo file will have the ownership and
+  # permissions of the person who deleted the file, and not
+  # necessarily of the original file.
+
   mv $mv_opts --no-clobber "${filename}" "${deletedfile}"
+  if [ "$?" != "0" ]; then
+    echo "${progname}: unable to move ${filename} to ${deletedfile}" 1>&2
+    rm "$deletedinfo"
+    exit 2
+  fi
 }
 
 for f in "$@"