| To: | yyyyyyyyyyyyyy@xxxxxxxxxxxxx |
|---|---|
| Subject: | cp -if a b: should it prompt? POSIX says `yes', most don't |
| From: | Jim Meyering <yyy@xxxxxxxxxxxx> |
| Date: | Tue, 17 Feb 2004 18:57:13 +0100 |
There is a discrepancy between POSIX and common practice with respect to how `cp -if a b' should work. According to POSIX, http://www.opengroup.org/onlinepubs/007904975/utilities/cp.html cp must prompt the user in this case (GNU cp and Solaris cp do this): $ touch a b; /bin/cp -if a b cp: overwrite b (yes/no)? However, many[1] existing implementations of cp do not prompt because they define -f to override any preceding -i option: $ touch a b; /bin/cp -if a b $ POSIX says that -i means `prompt' and that -f is unrelated. POSIX requires cp's -f option to make it so that if an existing destination file cannot be opened, cp removes it and tries again. But bear in mind that for both rm and mv, the -f and -i options *are* related. For both of those tools, a -f option cancels the effect of any preceding -i option. Note that RedHat has been using a patch that makes cp's behavior non-POSIX, yet consistent with that of most other systems, for years. I'm inclined to change the `upstream' GNU cp to be non-conforming, too. Should POSIX permit the existing behavior of cp on all of those other non-Solaris systems? Jim ------------- [1] The following systems provide an implementation of cp that is not POSIX compliant in that `cp -if a b' completes without prompting: Tru64 V5.1 openbsd 3.2 netbsd 1.6 HPUX B.11.23 Darwin 7.2.0 RedHat On the other side of the fence: solaris-5.9 /bin/cp solaris-5.9 /usr/xpg4/bin/cp cp from the GNU coreutils package |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: Stop signals and interruption of system calls on Linux, wojtek |
|---|---|
| Next by Date: | Re: cp -if a b: should it prompt? POSIX says `yes', most don't, Nick Stoughton |
| Previous by Thread: | Mailing list settings, Andrew Josey |
| Next by Thread: | Re: cp -if a b: should it prompt? POSIX says `yes', most don't, Nick Stoughton |
| Indexes: | [Date] [Thread] [All Lists] |