Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!uunet!usenix!std-unix From: ast@cs.vu.nl (Andy Tanenbaum) Newsgroups: comp.std.unix Subject: Query about P1003.2 'cp' utility Message-ID: <439@usenix.ORG> Date: 17 Aug 90 09:46:37 GMT Sender: std-unix@usenix.ORG Organization: Fac. Wiskunde & Informatica, VU, Amsterdam Lines: 52 Approved: jsq@usenix.org (Moderator, John Quarterman) X-Submissions: std-unix@uunet.uu.net From: Andy Tanenbaum While studying the P1003.2 description of the 'cp' utility, I ran into an ambiguity. In paragraph 4.13.2 (description), line 1985 & 1996-2000, it says: (1) If the destination path exists: (b) If the permissions of the file to which the destination path refers to do not permit writing, actions are performed equivalent to the unlink() #5.5.1[POSIX.1] function call using destination as the path argument, and, if this fails for any reason... In paragraph 4.13.3 (options), next page, lines 2010 & 2011 says: -f For each existing destination pathname, remove it and create a new file, without prompting for confirmation regardless of its permissions Now, I believe that the description should say: (b) If the permissions of the file to which the destination path refers to do not permit writing, or if the -f option is specified, ... to be consistent, but then "cp -f" would snap any existing links to the destination file, and even change the destination file mode, owner and group (without a -p being specified), while "cp" wouldn't. Example: -rw-r--r-- 1 user1 group1 srcfile -rw-rw-rw- 2 user2 group2 dstfile If user3 (group3) invokes cp srcfile dstfile, then the dstfile's mode, owner, group and links do not change. However, if cp -f srcfile dstfile is invoked, then the dstfile becomes: -rw-r--r-- 1 user3 group3 dstfile Now, this behavior might be correct, but is this effect really intended by P1003.2? Possibly, the user that wish to replace the dstfile entirely (as opposed to overwriting it) should use rm BEFORE calling cp, and the -f option should be used only to suppress interaction with the user. Maybe draft 10 clarifies the situation? Vincent Archer | Email:archer%segin4.segin.fr@relay.prime.com "People that are good at finding excuses are never good at anything else" (Posted by Andy Tanenbaum because Vincent does not have USENET access.) Volume-Number: Volume 21, Number 41