mlprof bug

Henry Cejtin henry@sourcelight.com
Mon, 21 Jan 2002 13:58:25 -0600


Yes,  renaming files pretty much always visibly different semantics, so it is
NOT correct to do it in most cases.  Still, I think you are correct.

Note the mv command in GNU is completely fucked  up.   Traditionally  mv  has
always  done  the  kinds  of things you mention, which is fine.  I don't much
like it, but the GNU version does the following: it  tries  the  rename.   If
that  fails,  it  does  a  copy.   After  the copy it tries to remove the old
version.  If it doesn't have write permission, the unlink fails and  you  now
have two copies.

The  moral is that you have to test all the permissions first at least.  Even
then you have to handle the case where the permissions change.  In that  case
the  correct thing is probably to remove the copy, but then what about if the
copy file already existed.  It is too late to bring it back.

All of these are why I don't like the idea of mv trying to be `clever'.

None  of  this  really  applies  too  much  to  a File.move function, but the
permission checks still must be performed before the copy.