Hi,

Either this is bug or an unintuitive feature.

s...@lelux ~/foo touch src dest
s...@lelux ~/foo chmod g-rwx src
s...@lelux ~/foo chmod g+rwx dest
s...@lelux ~/foo ls -l
total 0
-rw-rwxr-- 1 sake sake 0 2009-03-30 13:16 dest
-rw----r-- 1 sake sake 0 2009-03-30 13:16 src
s...@lelux ~/foo cp --force --backup=t src dest
s...@lelux ~/foo ls -l
total 0
-rw----r-- 1 sake sake 0 2009-03-30 13:16 dest
-rw-rwxr-- 1 sake sake 0 2009-03-30 13:16 dest.~1~
-rw----r-- 1 sake sake 0 2009-03-30 13:16 src

In case this is bug the patch is good. In case of feature it should be
modified to make sure that permissions are different.

-- 
   Sami Kerola
   http://www.iki.fi/kerolasa/
From 2c4e6f75ced048ec24c13ec8862bc6ae0a6ddb4d Mon Sep 17 00:00:00 2001
From: Sami Kerola <[email protected]>
Date: Mon, 30 Mar 2009 13:11:26 +0200
Subject: [PATCH] check that dest and backup permissions are same
Cc: [email protected]

---
 tests/cp/backup-dst-perm |   51 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)
 create mode 100644 tests/cp/backup-dst-perm

diff --git a/tests/cp/backup-dst-perm b/tests/cp/backup-dst-perm
new file mode 100644
index 0000000..4d6b12c
--- /dev/null
+++ b/tests/cp/backup-dst-perm
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# Test cp destination permissions are not changed when --backup specified
+# and source permissions are not asked to be preserved (-p).
+#
+# Copyright (C) 1997, 1999, 2002, 2004, 2006-2008 Free Software Foundation, 
Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+if test "$VERBOSE" = yes; then
+  set -x
+  cp --version
+fi
+
+. $srcdir/test-lib.sh
+
+file_src=bdpa
+file_dst=bdpb
+temp_files="$file_src $file_dst"
+rm -f $temp_files
+
+fail=0
+touch $temp_files || fail=1
+chmod g-rwx $file_src
+chmod g+rwx $file_dst
+
+# Specify both version control and suffix so the environment variables
+# (possibly set by the user running these tests) aren't used.
+cp --force --backup=t $file_src $file_dst || fail=1
+
+test -f $file_src || fail=1
+test -f $file_dst || fail=1
+test -f $file_dst.~1~ || fail=1
+
+dst_mode=`ls -ld $file_dst|cut -b-10`
+backup_mode=`ls -ld $file_dst.~1~|cut -b-10`
+
+test "$backup_mode" = "$dst_mode" || fail=1
+
+Exit $fail
-- 
1.6.0.6

_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to