[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cp preserves mode with --no-preserve=mode
From: |
Jim Meyering |
Subject: |
Re: cp preserves mode with --no-preserve=mode |
Date: |
Fri, 28 Sep 2012 12:39:04 +0200 |
Ondrej Oprala wrote:
...
> The .explicit_no_preserve_mode flag should now be turned off when
> --preserve=all
> is run into.
> I've also added a test for the mixed options next to other tests in
> preserve-mode.sh.
...
> Subject: [PATCH] cp: Fix the --no-preserve=mode option
>
> * NEWS: Mention the fix.
> * TODO: Remove an entry.
> * src/copy.c (copy_reg): Add a condition to properly
> handle the --no-preserve=mode option for files
> (copy_internal): Add a condition to properly handle the
> --no-preserve=mode option for directories.
> * src/copy.h (struct cp_options): Add a new boolean.
> * src/cp.c (cp_option_init,decode_preserve_arg): Set the
> new boolean value according to specified options.
> * src/install.c (struct cp_options): Initialize the new boolean.
> * src/mv.c (struct cp_options): Initialize the new boolean.
> * tests/cp/preserve-mode.sh: Add a new test.
> * tests/local.mk: Add the new test to the list.
...
Thank you.
The only remaining problem was that your change induced a
new failure in tests/cp/link-preserve.sh:
FAIL: tests/cp/link-preserve
============================
...
+ cp -a --no-preserve=mode a b
++ cut -b-10
++ ls -l b
+ mode=-rw-------
+ test -rw------- = -rwx------
+ fail=1
I added this to the log:
* tests/cp/link-preserve.sh (-a --no-preserve=mode): Adjust the
expected perms: now, --no-preserve=mode overrides the --preserve=mode
that is inherent in -a, as it should.
and squashed this change into your change set:
diff --git a/tests/cp/link-preserve.sh b/tests/cp/link-preserve.sh
index 0c75d30..bb3b244 100755
--- a/tests/cp/link-preserve.sh
+++ b/tests/cp/link-preserve.sh
@@ -84,7 +84,7 @@ touch a; chmod 731 a
umask 077
cp -a --no-preserve=mode a b
mode=$(ls -l b|cut -b-10)
-test "$mode" = "-rwx------" || fail=1
+test "$mode" = "-rw-------" || fail=1
umask 022
# --------------------------------------
Thus, with that change, "make check" now passes, and I've pushed the fix.