bug-coreutils
[Top][All Lists]
Advanced

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

Re: question for cp tools


From: Bob Proulx
Subject: Re: question for cp tools
Date: Sat, 5 Mar 2005 10:09:50 -0700
User-agent: Mutt/1.5.6+20040907i

Hi Jim

Jim Meyering wrote:
> I've noticed that my use of `source' below might be misunderstood.
> Here's a snippet from the documentation that should help:
> 
>      mv [OPTION]... SOURCE DEST
>      mv [OPTION]... SOURCE... DIRECTORY

I can see that you are emphasizing the difference between the set of
source and the set of destination files and the rules applied to those
two difference sets.  However, fundamentally why are they different?
I don't think they should be treated differently.

Note that I have never heard discussion of this with 'cp' but only
with 'mv'.  Fundamentally I think 'mv' and 'cp' are conceptually
different.

> In general, you can add mv's --backup option:
> 
>    mv --backup=numbered */*/foo ../ARCHIVE/

So, why does --backup=numbered work but --backup=simple fail?

  cd /tmp
  rm -rf x y z
  mkdir x y z
  touch x/foo
  cp x/foo y/foo
  mv --backup=numbered x/foo y/foo z/
  ls z
  foo  foo.~1~

  rm -rf x y z
  mkdir x y z
  touch x/foo
  cp x/foo y/foo
  mv --backup=simple x/foo y/foo z/
  mv: will not overwrite just-created `z/foo' with `y/foo'

I tried the 'mv -b' option previously and seeing that it failed
stopped looking at that option thereafter and never noticed that
numbered backups worked.  Shouldn't they basically be the same?  (I
know the response is that with backup=simple you end up deleting the
third SOURCE file and that violated the principle.)

> Well, we can't really use -f/--force, because -f has POSIX-specified
> behavior controlling whether mv prompts -- not whether it refuses to
> do something that might be confusing.  Besides, --force applies to
> *destination* files, which is a little ambiguous in this case, since a
> SOURCE file is moved to its destination, and later mv sees that renamed
> SOURCE file as the destination for another move.

I think that logic is defendable.  I will acquiesce here.

> The difference is that `mv foo bar' unlinks a *destination* file,
> which is what everyone expects mv to do.  Few realize that a
> POSIX-compliant mv can sometimes clobber *SOURCE* files, too.

I understand what is happening and so that is why to me this is only
"annoying" on the scale and not really broken.  I can code around it.
But I think I am sticking to using mv in a for-loop to avoid it.

Bob




reply via email to

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