diff --git a/bin/cp/cp.1 b/bin/cp/cp.1 --- a/bin/cp/cp.1 +++ b/bin/cp/cp.1 @@ -31,7 +31,7 @@ .\" .\" @(#)cp.1 8.3 (Berkeley) 4/18/94 .\" -.Dd February 23, 2022 +.Dd November 18, 2023 .Dt CP 1 .Os .Sh NAME @@ -44,7 +44,7 @@ .Op Fl H | Fl L | Fl P .Oc .Op Fl f | i | n -.Op Fl alpsvx +.Op Fl alNpsvx .Ar source_file target_file .Nm .Oo @@ -52,15 +52,15 @@ .Op Fl H | Fl L | Fl P .Oc .Op Fl f | i | n -.Op Fl alpsvx +.Op Fl alNpsvx .Ar source_file ... target_directory .Nm .Op Fl f | i | n -.Op Fl alPpsvx +.Op Fl alNPpsvx .Ar source_file target_file .Nm .Op Fl f | i | n -.Op Fl alPpsvx +.Op Fl alNPpsvx .Ar source_file ... target_directory .Sh DESCRIPTION In the first synopsis form, the @@ -90,6 +90,10 @@ If the .Fl R option is specified, all symbolic links are followed. +.It Fl N +When used with +.Fl p , +suppress copying file flags. .It Fl P No symbolic links are followed. This is the default if the diff --git a/bin/cp/cp.c b/bin/cp/cp.c --- a/bin/cp/cp.c +++ b/bin/cp/cp.c @@ -84,7 +84,7 @@ PATH_T to = { to.p_path, emptystring, "" }; -int fflag, iflag, lflag, nflag, pflag, sflag, vflag; +int Nflag, fflag, iflag, lflag, nflag, pflag, sflag, vflag; static int Hflag, Lflag, Rflag, rflag; volatile sig_atomic_t info; @@ -103,7 +103,7 @@ fts_options = FTS_NOCHDIR | FTS_PHYSICAL; Pflag = 0; - while ((ch = getopt(argc, argv, "HLPRafilnprsvx")) != -1) + while ((ch = getopt(argc, argv, "HLNPRafilnprsvx")) != -1) switch (ch) { case 'H': Hflag = 1; @@ -113,6 +113,9 @@ Lflag = 1; Hflag = Pflag = 0; break; + case 'N': + Nflag = 1; + break; case 'P': Pflag = 1; Hflag = Lflag = 0; diff --git a/bin/cp/extern.h b/bin/cp/extern.h --- a/bin/cp/extern.h +++ b/bin/cp/extern.h @@ -38,7 +38,7 @@ } PATH_T; extern PATH_T to; -extern int fflag, iflag, lflag, nflag, pflag, sflag, vflag; +extern int Nflag, fflag, iflag, lflag, nflag, pflag, sflag, vflag; extern volatile sig_atomic_t info; __BEGIN_DECLS diff --git a/bin/cp/utils.c b/bin/cp/utils.c --- a/bin/cp/utils.c +++ b/bin/cp/utils.c @@ -355,7 +355,7 @@ rval = 1; } - if (!gotstat || fs->st_flags != ts.st_flags) + if (!Nflag && (!gotstat || fs->st_flags != ts.st_flags)) if (fdval ? fchflags(fd, fs->st_flags) : (islink ? lchflags(to.p_path, fs->st_flags) :