Patch for cp(1)
Tom Rhodes
trhodes at FreeBSD.org
Wed Mar 30 15:19:20 PST 2005
Hi -standards.
What do people think of the following patch to cp.c:
Index: cp.c
===================================================================
RCS file: /home/ncvs/src/bin/cp/cp.c,v
retrieving revision 1.51
diff -u -r1.51 cp.c
--- cp.c 10 Jan 2005 08:39:21 -0000 1.51
+++ cp.c 30 Mar 2005 15:42:43 -0000
@@ -84,7 +84,7 @@
PATH_T to = { to.p_path, emptystring, "" };
int fflag, iflag, nflag, pflag, vflag;
-static int Rflag, rflag;
+static int Rflag;
volatile sig_atomic_t info;
enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
@@ -135,7 +135,7 @@
pflag = 1;
break;
case 'r':
- rflag = 1;
+ Rflag = 1;
break;
case 'v':
vflag = 1;
@@ -151,16 +151,7 @@
usage();
fts_options = FTS_NOCHDIR | FTS_PHYSICAL;
- if (rflag) {
- if (Rflag)
- errx(1,
- "the -R and -r options may not be specified together.");
- if (Hflag || Lflag || Pflag)
- errx(1,
- "the -H, -L, and -P options may not be specified with the -r option.");
- fts_options &= ~FTS_PHYSICAL;
- fts_options |= FTS_LOGICAL;
- }
+
if (Rflag) {
if (Hflag)
fts_options |= FTS_COMFOLLOW;
@@ -224,12 +215,12 @@
* the initial mkdir().
*/
if (r == -1) {
- if (rflag || (Rflag && (Lflag || Hflag)))
+ if ((Rflag && (Lflag || Hflag))
stat(*argv, &tmp_stat);
else
lstat(*argv, &tmp_stat);
- if (S_ISDIR(tmp_stat.st_mode) && (Rflag || rflag))
+ if (S_ISDIR(tmp_stat.st_mode) && (Rflag)
type = DIR_TO_DNE;
else
type = FILE_TO_FILE;
@@ -414,7 +405,7 @@
}
break;
case S_IFDIR:
- if (!Rflag && !rflag) {
+ if (!Rflag) {
warnx("%s is a directory (not copied).",
curr->fts_path);
(void)fts_set(ftsp, curr, FTS_SKIP);
So, why/what am I doing:
My copy of SuSv3 states that -r is about to become obsolete;
The -r option fails (actually hangs) when trying to copy a fifo
file within a directory. It does this on both CURRENT,
STABLE and SunOS 5.9.
The idea was to make -r a synonym for -R, which works in all of
these cases.
I plan to fix the manual page as -r is not historical, it was
implemenation dependent. Comments/suggestions? Yes, manual
page commit would done together of course.
Also reviewed to be cool by das and philip. :)
--
Tom Rhodes
More information about the freebsd-standards
mailing list