autoconf
[Top][All Lists]
Advanced

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

Re: Portability of "mv -f"


From: Ian Lance Taylor
Subject: Re: Portability of "mv -f"
Date: 21 Sep 2000 18:55:52 -0700

   From: Russ Allbery <address@hidden>
   Date: 21 Sep 2000 18:10:18 -0700

   > I believe that mv -f is fully portable.  I think the only portable
   > options to mv are -f and -i.

   I know that cp -f definitely *isn't* portable.  I forget where it
   misbehaved, but it was a bug report against one of my earlier packages.
   Unfortunately, it was for an old Makefile whose revision history I didn't
   save when I rewrote the package as a Perl module.  SunOS, maybe?

Yes, SunOS cp does not support -f.  SunOS mv, however, does.

SunOS cp supports -i, -p, -r.  I don't think -p or -r are portable.

It's possible to deduce why mv and cp are different with respect to
-f.  mv prompts by default before overwriting a read-only file.  cp
does not.  Therefore, mv requires a -f option, but cp does not.  mv
and cp behave differently with respect to read-only files because the
simplest form of cp can not overwrite a read-only file, but the
simplest form of mv can.  This is because cp opens the target for
write access, whereas mv simply calls link (or, in newer systems,
rename).

Ian


reply via email to

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