www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3862] New: std.copy does not have the same behavior as cp

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3862

           Summary: std.copy does not have the same behavior as cp
           Product: D
           Version: 2.040
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: jmdavisProg gmail.com


--- Comment #0 from Jonathan M Davis <jmdavisProg gmail.com> 2010-02-28
02:32:10 PST ---
Created an attachment (id=575)
Matrix of cp's behavior vs std.copy (putting it directly in the bug report
would have ruined the formatting)

std.copy() does not behave the same way as cp. I'm not sure that that's
completely a bad thing, but there are some cases where I think that it's
definitely broken as is. I've attached a matrix with a list of possible
combinations of files, directories, and symlinks (I _think_ that I got all of
the possible combinations). Many work exactly like cp, others quite
differently.

The biggest problem area is when trying to copy files to themselves. std.copy
doesn't guard against it, and it generally results in the deletion of the file
(depending on whether symlinks were involved). The one area where it works
differently which we may or may not want to change is copying a file to a
directory. cp puts the file in the directory while std.copy throws an
exception. My first reaction would be that it should be the same as cp, but I
don't know what happens on Windows, and I could see an argument that both the
source and destination should be files.

Regardless of whether we want std.copy to exactly match cp in behavior, there
_are_ cases where std.copy is currently broken.

I suppose that this is tangentially related to bug 3848, but since it doesn't
check whether a file is a file or a directory, and it seems to currently work
correctly with symlinks, I don't think that bug 3848 really matters to this
one.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 28 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3862


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 09 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3862


David Simcha <dsimcha yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dsimcha yahoo.com


--- Comment #1 from David Simcha <dsimcha yahoo.com> 2011-08-30 12:51:01 PDT ---
IMHO it's **much** more important for Phobos to be consistent across operating
systems than to be consistent with the native file copying command on each OS. 
Obviously they don't always conflict but where they do I think the former
should be favored.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 30 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3862



--- Comment #2 from Andrei Alexandrescu <andrei metalanguage.com> 2011-08-30
14:41:36 PDT ---
I think there's value in this insofar as we frame it as "std.file.copy doesn't
obey the principle of least astonishment". Taking a peek at cp as an example is
fine as long as we're in the business of having a robust file copy routine and
not in the business of emulating everything cp does.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 30 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3862



--- Comment #3 from Andrei Alexandrescu <andrei erdani.com> 2013-02-26 09:15:43
PST ---
Jonathan, OK to assign this to you?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 26 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3862



--- Comment #4 from Jonathan M Davis <jmdavisProg gmx.com> 2013-02-26 10:12:59
PST ---
 Jonathan, OK to assign this to you?
Fine with me. I'd forgotten about this, and it really should be taken care of. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 26 2013