summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorGian Piero Carrubba <gpiero@rm-rf.it>2013-11-07 23:35:52 +0100
committerBernhard Voelker <mail@bernhard-voelker.de>2013-11-07 23:45:22 +0100
commitbf6bf52dce37832b03ecfbe1b3a3b104f532df42 (patch)
treec62463b576c33400b029667a0991367c9da47b7c /doc
parent2c6736f92fc7d2f310714473ea84ceff57e01da2 (diff)
downloadcoreutils-bf6bf52dce37832b03ecfbe1b3a3b104f532df42.tar.xz
cp: fix --link regarding the dereferencing of symbolic links
* src/copy.c (create_hard_link): Add a bool 'dereference' parameter, and pass AT_SYMLINK_FOLLOW as 'flags' to linkat() when dereference is true. (should_dereference): Add new 'bool' function to determine if a file should be dereferenced or not. (copy_internal): Use the above new should_dereference() and remember its return value in a new local bool 'dereference' variable. Use that in all three calls to create_hard_link(). * src/cp.c (main): after parsing the options, if x.dereference is still DEFEF_UNDEFINED and the x.recursive is true, then only set x.dereference to DEREF_NEVER iff --link was not specified. * doc/coreutils.texi (cp invocation): Mention that cp(1) does not follow symbolic links in the source when --link is specified. Likewise in the description of the -R option when used together with that option. * tests/cp/same-file.sh: Adapt the expected results for the -fl, the -bl and the -bfl tests. * tests/cp/link-deref.sh: Add a new test. * tests/local.mk (all_tests): Reference the above new test. * NEWS (Changes in behavior): Mention the change. This fixes http://bugs.gnu.org/15173 Co-authored-by: Bernhard Voelker <mail@bernhard-voelker.de>
Diffstat (limited to 'doc')
-rw-r--r--doc/coreutils.texi7
1 files changed, 4 insertions, 3 deletions
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index cc806d52c..3ae39d18c 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -8052,8 +8052,8 @@ copy recursively by descending into source directories and copying files
to corresponding destination directories.
When copying from a symbolic link, @command{cp} normally follows the
-link only when not copying
-recursively. This default can be overridden with the
+link only when not copying recursively or when @option{--link}
+(@option{-l}) is used. This default can be overridden with the
@option{--archive} (@option{-a}), @option{-d}, @option{--dereference}
(@option{-L}), @option{--no-dereference} (@option{-P}), and
@option{-H} options. If more than one of these options is specified,
@@ -8327,7 +8327,8 @@ any missing intermediate directories.
@cindex recursively copying directories
@cindex non-directories, copying as special files
Copy directories recursively. By default, do not follow symbolic
-links in the source; see the @option{--archive} (@option{-a}), @option{-d},
+links in the source unless used together with the @option{--link}
+(@option{-l}) option; see the @option{--archive} (@option{-a}), @option{-d},
@option{--dereference} (@option{-L}), @option{--no-dereference}
(@option{-P}), and @option{-H} options. Special files are copied by
creating a destination file of the same type as the source; see the