diff options
author | trhodes <trhodes@FreeBSD.org> | 2006-10-07 22:14:43 +0000 |
---|---|---|
committer | trhodes <trhodes@FreeBSD.org> | 2006-10-07 22:14:43 +0000 |
commit | 06666564b4406194fb69bd44baae12c30024211e (patch) | |
tree | 2a9f611b9d438792c74b98bd7aebfa0f89229ba2 /bin/cp/cp.c | |
parent | 1f27dd98e09d99c5874f668c44e377aadaf8f8c8 (diff) | |
download | FreeBSD-src-06666564b4406194fb69bd44baae12c30024211e.zip FreeBSD-src-06666564b4406194fb69bd44baae12c30024211e.tar.gz |
Make -r a synonym for -R, similar to behavior on Linux while being backwards
compatible with old -r behavior with regards to -L. You can now copy fifos
and other special files with -r.
Reviewed by: -standards (long ago), das, bde
Approved by: bde (recently)
Diffstat (limited to 'bin/cp/cp.c')
-rw-r--r-- | bin/cp/cp.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/bin/cp/cp.c b/bin/cp/cp.c index cad0710..13757f0 100644 --- a/bin/cp/cp.c +++ b/bin/cp/cp.c @@ -138,7 +138,8 @@ main(int argc, char *argv[]) pflag = 1; break; case 'r': - rflag = 1; + rflag = Lflag = 1; + Hflag = Pflag = 0; break; case 'v': vflag = 1; @@ -155,15 +156,12 @@ main(int argc, char *argv[]) fts_options = FTS_NOCHDIR | FTS_PHYSICAL; if (rflag) { - 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 && !Hflag && !Pflag) + Rflag = 1; if (Rflag) { if (Hflag) fts_options |= FTS_COMFOLLOW; @@ -227,12 +225,12 @@ main(int argc, char *argv[]) * 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; @@ -420,7 +418,7 @@ copy(char *argv[], enum op type, int fts_options) } 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); |