bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8636: cp -x flag does not work


From: Jim Meyering
Subject: bug#8636: cp -x flag does not work
Date: Mon, 09 May 2011 14:07:49 +0200

tags 8636 + notabug
thanks

address@hidden wrote:
> context: copy a linux system to a directory where, after chrooting to that
> directory, i could safely  torture and mangle the duplicate system.
>
> the command used was cp -xvdpR /*   /newdirectory
>
> where / contains mounted other(not on the drive / is on) filesystems. these
> are nfs mounts(direct and via ssh), mounted hard drives, and mounted loop
> drives.
>
> the guilty party is apparently the wildcard
>
> the command as given above copies everything and descends all directories on
> all mounted file systems under / no matter what they are.
>
> the command:  cp -xvdp /<otherfs-dir>/*   /newdirectory

Thanks for explaining.
With -x, cp considers each specified source directory when applying this rule:

    `-x'
    `--one-file-system'
         Skip subdirectories that are on different file systems from the
         one that the copy started on.  However, mount point directories
         _are_ copied.

So this might have been what you intended, assuming that /newdirectory
is not on the same file system as "/":

    cp -xvdp / /newdirectory

Even if it is on the same file system, it should work,
but you should get a diagnostic about cp refusing to copy
/newdirectory into itself.

> descends into the top level of the  otherfs dir and copies the files
> therein, but does not descend into other directories.
>
> so the wildcard essentially negates -x and this was not anticipated
> behavior. checking the docs i did not find any mention of this.
>
> if this is WAD, then it should be documented, however, i don't think that
> someone using the -x wants a wildcard to undo that spec especially in a dir
> with several mounts on subdirectories.

I think it even works as _documented_ (in the "info" documentation) ;-)
Yes, the five-word description in --help (and hence in "man cp") is too
succinct, but at the end of that man page, you should see a note explaining
that "info cp" will give you the real documentation.

Would you like to suggest wording that would make it clearer?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]