GNU bug report logs - #17578
cp(1) man page: behavior of "cp -R dir target" on symbolic links is unclear

Previous Next

Package: coreutils;

Reported by: Vincent Lefevre <vincent <at> vinc17.net>

Date: Sat, 24 May 2014 15:08:02 UTC

Severity: normal

Tags: wontfix

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 17578 in the body.
You can then email your comments to 17578 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#17578; Package coreutils. (Sat, 24 May 2014 15:08:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Vincent Lefevre <vincent <at> vinc17.net>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sat, 24 May 2014 15:08:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Vincent Lefevre <vincent <at> vinc17.net>
To: bug-coreutils <at> gnu.org
Subject: cp(1) man page: behavior of "cp -R dir target" on symbolic links is
 unclear
Date: Sat, 24 May 2014 17:07:05 +0200
The cp(1) man page does not describe the behavior on symbolic links
when copying recursively. It appears that in such a case, cp does not
dereference the links (this is also what the info file says: "When
copying from a symbolic link, `cp' normally follows the link only
when not copying recursively."). Tested with cp (GNU coreutils) 8.21
on Debian/unstable.

As the usual behavior of utilities on symbolic links is to follow the
links, this may be surprising to the user who only reads the man page
(even if he knows POSIX, as POSIX doesn't specify the behavior if
only -R is used).

So, the man page should say that by default (e.g. without -H, -L, -P),
cp follows source symbolic links only when not copying recursively.

-- 
Vincent Lefèvre <vincent <at> vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Information forwarded to bug-coreutils <at> gnu.org:
bug#17578; Package coreutils. (Sat, 24 May 2014 17:30:04 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Vincent Lefevre <vincent <at> vinc17.net>, bug-coreutils <at> gnu.org
Subject: Re: bug#17578: cp(1) man page: behavior of "cp -R dir target" on
 symbolic links is unclear
Date: Sat, 24 May 2014 10:28:30 -0700
Vincent Lefevre wrote:
> this is also what the info file says: "When
> copying from a symbolic link, `cp' normally follows the link only
> when not copying recursively."

Must be an old version; the current text says "When copying from a 
symbolic link, 'cp' normally follows the link only when not copying 
recursively or when '--link' ('-l') is used."  A bit complicated, 
unfortunately; don't know whether that detail is worth adding to the 
--help output (which the man page is derived from).




Information forwarded to bug-coreutils <at> gnu.org:
bug#17578; Package coreutils. (Sat, 24 May 2014 17:39:01 GMT) Full text and rfc822 format available.

Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Vincent Lefevre <vincent <at> vinc17.net>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: bug-coreutils <at> gnu.org
Subject: Re: bug#17578: cp(1) man page: behavior of "cp -R dir target" on
 symbolic links is unclear
Date: Sat, 24 May 2014 19:37:43 +0200
On 2014-05-24 10:28:30 -0700, Paul Eggert wrote:
> Vincent Lefevre wrote:
> >this is also what the info file says: "When
> >copying from a symbolic link, `cp' normally follows the link only
> >when not copying recursively."
> 
> Must be an old version;

The man page says:

GNU coreutils 8.21                April 2014                             CP(1)

April 2014, thus not that old.

-- 
Vincent Lefèvre <vincent <at> vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Information forwarded to bug-coreutils <at> gnu.org:
bug#17578; Package coreutils. (Sun, 25 May 2014 02:20:02 GMT) Full text and rfc822 format available.

Message #14 received at 17578 <at> debbugs.gnu.org (full text, mbox):

From: Bob Proulx <bob <at> proulx.com>
To: Vincent Lefevre <vincent <at> vinc17.net>
Cc: 17578 <at> debbugs.gnu.org
Subject: Re: bug#17578: cp(1) man page: behavior of "cp -R dir target" on
 symbolic links is unclear
Date: Sat, 24 May 2014 20:19:08 -0600
Vincent Lefevre wrote:
> Paul Eggert wrote:
> > Must be an old version;
> 
> The man page says:
> GNU coreutils 8.21             April 2014                    CP(1)
> April 2014, thus not that old.

On your system that must be the date when the man page was formatted.
It isn't the date when the version was released.  Version 8.21 was
released 2013-02-14 and so is now a little over a year old.

(Which I still consider relatively recent.  But a year ago recent not
a month ago recent.)

Bob




Information forwarded to bug-coreutils <at> gnu.org:
bug#17578; Package coreutils. (Sun, 25 May 2014 11:14:01 GMT) Full text and rfc822 format available.

Message #17 received at 17578 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Vincent Lefevre <vincent <at> vinc17.net>, 17578 <at> debbugs.gnu.org
Subject: Re: bug#17578: cp(1) man page: behavior of "cp -R dir target" on
 symbolic links is unclear
Date: Sun, 25 May 2014 12:13:42 +0100
On 05/24/2014 04:07 PM, Vincent Lefevre wrote:
> The cp(1) man page does not describe the behavior on symbolic links
> when copying recursively. It appears that in such a case, cp does not
> dereference the links (this is also what the info file says: "When
> copying from a symbolic link, `cp' normally follows the link only
> when not copying recursively."). Tested with cp (GNU coreutils) 8.21
> on Debian/unstable.
> 
> As the usual behavior of utilities on symbolic links is to follow the
> links, this may be surprising to the user who only reads the man page
> (even if he knows POSIX, as POSIX doesn't specify the behavior if
> only -R is used).
> 
> So, the man page should say that by default (e.g. without -H, -L, -P),
> cp follows source symbolic links only when not copying recursively.

I suppose we could adjust --help (and thus the man page) like:

  -  -R, -r, --recursive          copy directories recursively
  +  -R, -r, --recursive          copy directories recursively (implies -P)







Information forwarded to bug-coreutils <at> gnu.org:
bug#17578; Package coreutils. (Sun, 25 May 2014 20:28:02 GMT) Full text and rfc822 format available.

Message #20 received at 17578 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Pádraig Brady <P <at> draigBrady.com>, 
 Vincent Lefevre <vincent <at> vinc17.net>, 17578 <at> debbugs.gnu.org
Subject: Re: bug#17578: cp(1) man page: behavior of "cp -R dir target" on
 symbolic links is unclear
Date: Sun, 25 May 2014 13:27:00 -0700
Pádraig Brady wrote:
>    -  -R, -r, --recursive          copy directories recursively
>    +  -R, -r, --recursive          copy directories recursively (implies -P)

Unfortunately it's not that simple, as -R doesn't always imply -P.




Information forwarded to bug-coreutils <at> gnu.org:
bug#17578; Package coreutils. (Mon, 26 May 2014 09:00:05 GMT) Full text and rfc822 format available.

Message #23 received at 17578 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 17578 <at> debbugs.gnu.org, Vincent Lefevre <vincent <at> vinc17.net>
Subject: Re: bug#17578: cp(1) man page: behavior of "cp -R dir target" on
 symbolic links is unclear
Date: Mon, 26 May 2014 09:59:04 +0100
tag 17578 wontfix
close 17578
stop

On 05/25/2014 09:27 PM, Paul Eggert wrote:
> Pádraig Brady wrote:
>>    -  -R, -r, --recursive          copy directories recursively
>>    +  -R, -r, --recursive          copy directories recursively (implies -P)
> 
> Unfortunately it's not that simple, as -R doesn't always imply -P.

Yes we shouldn't assume users would know that -H and -L would override -P.
Also --link is recently wound up in this. Hence it's not easy to describe.
We could accurately describe using something like the following, but given
that the info docs are correct and complete here and that most users use
-a anyway which already explicitly considers --no-dereference, it's probably
best to err on the side of conciseness in the man/--help and let users
refer to info for complete docs.

thanks,
Pádraig.

diff --git a/src/cp.c b/src/cp.c
index 243d6af..878266a 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -206,7 +206,8 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\
       --parents                use full source file name under DIRECTORY\n\
 "), stdout);
       fputs (_("\
-  -R, -r, --recursive          copy directories recursively (implies -P)\n\
+  -R, -r, --recursive          copy directories recursively. Without -H,-L or\n\
+                                 --link, implies --no-dereference\n\
       --reflink[=WHEN]         control clone/CoW copies. See below\n\
       --remove-destination     remove each existing destination file before\n\
                                  attempting to open it (contrast with --force)\





Added tag(s) wontfix. Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Mon, 26 May 2014 09:00:06 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 17578 <at> debbugs.gnu.org and Vincent Lefevre <vincent <at> vinc17.net> Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Mon, 26 May 2014 09:00:08 GMT) Full text and rfc822 format available.

Information forwarded to bug-coreutils <at> gnu.org:
bug#17578; Package coreutils. (Mon, 26 May 2014 09:32:02 GMT) Full text and rfc822 format available.

Message #30 received at 17578 <at> debbugs.gnu.org (full text, mbox):

From: Vincent Lefevre <vincent <at> vinc17.net>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: Paul Eggert <eggert <at> cs.ucla.edu>, 17578 <at> debbugs.gnu.org
Subject: Re: bug#17578: cp(1) man page: behavior of "cp -R dir target" on
 symbolic links is unclear
Date: Mon, 26 May 2014 11:31:21 +0200
On 2014-05-26 09:59:04 +0100, Pádraig Brady wrote:
> Yes we shouldn't assume users would know that -H and -L would override -P.
> Also --link is recently wound up in this. Hence it's not easy to describe.

It could be described like in the info file.

> We could accurately describe using something like the following, but given
> that the info docs are correct and complete here

Not all users use the info docs (I find man / --help easier to use).

> and that most users use -a anyway which already explicitly considers
> --no-dereference,

That's the point of this bug report: I usually use -a, which implies
--no-dereference, so that I thought that -R alone would avoid this
--no-dereference, but this is not the way cp behaves.

> it's probably best to err on the side of conciseness in the
> man/--help and let users refer to info for complete docs.

That would just be one sentence below the list of options (a bit like
in the info doc).

-- 
Vincent Lefèvre <vincent <at> vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 23 Jun 2014 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 59 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.