bug-coreutils
[Top][All Lists]
Advanced

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

Re: cp --archive with special files


From: Jim Meyering
Subject: Re: cp --archive with special files
Date: Mon, 02 Jul 2007 11:29:33 +0200

Mike Frysinger <address@hidden> wrote:
> a user just pointed out this corner case with -a which i think is a bug ...
> seems to happen with any special file (fifo, device node, etc...), but it was
> first noticed with a device node

Hi Mike,
Thanks for the report.
>
> # mkdir src dst
> # touch dst/null
> # mknod src/null c 1 3
> # cp -a src/* dst/
> cp: cannot create special file `d/null': File exists
> # cp -a s/null d/null -f
> cp: cannot create special file `d/null': File exists
> # ls -l d/null
> -rw-r--r-- 1 root root 0 2007-06-28 05:41 d/null

Hmm... looks like you mixed up your examples: you create src and dst,
but operate on "s" and "d"...  But I get the point.

> i think in the case where cp encounters the destination as being a regular
> file and the source as being a special file, it should simply unlink the
> destination and create the destination the same as if it didnt exist in the
> first place

The spec seems to require the current behavior:
[see 4b and the description of -f.
 Note that -a isn't standard, but presume -pR, which are]:

    http://www.opengroup.org/susv3xcu/cp.html

While it's not entirely clear what must happen when failing to create
a special destination file that is not a symlink or fifo, I think the
intent is clear -- and it doesn't permit removing the destination.

Also, -f applies only to regular files.

If you can depend on GNU cp, use --remove-destination instead of -f.
That will make cp do what you want.

Jim




reply via email to

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