[hackers] [sbase] cp: Rename -d option to -P || Michael Forney
commit e14e0beccef66be52166f27979fedc19283d62be
Author: Michael Forney <mforney_AT_mforney.org>
Date: Mon Dec 8 03:25:24 2014 +0000
cp: Rename -d option to -P
The -d option is a GNU extension and is equivalent to its "-P
--preserve=links" options.
Since we don't implement the --preserve=links functionality anyway (it
means preserve hard links between files), just call it -P, which is
specified by POSIX.
Additionally, there is no need to check for cp_Pflag again before
copying the symlink itself because the only way the mode in the stat
will indicate a symlink is if we used lstat (which we only do if -P is
specified).
diff --git a/cp.1 b/cp.1
index f0f5b65..95f39c3 100644
--- a/cp.1
+++ b/cp.1
_AT_@ -8,7 +8,7 @@ cp \- copy files and directories
.RI [ name ]
.P
.B cp
-.RB [ \-adpRrv ]
+.RB [ \-aPpRrv ]
.RI [ file ...]
.RI [ directory ]
.SH DESCRIPTION
_AT_@ -21,8 +21,8 @@ they will be copied into the given directory.
preserve mode, timestamp, links and permissions.
Implies \-d, \-p, \-r.
.TP
-.B \-d
-don't dereference links. preserve links.
+.B \-P
+don't dereference symbolic links.
.TP
.B \-p
preserve mode, timestamp and permissions.
diff --git a/cp.c b/cp.c
index f1c3d9b..f3b91f1 100644
--- a/cp.c
+++ b/cp.c
_AT_@ -19,10 +19,10 @@ main(int argc, char *argv[])
ARGBEGIN {
case 'a':
/* implies -dpr */
- cp_aflag = cp_dflag = cp_pflag = cp_rflag = 1;
+ cp_aflag = cp_Pflag = cp_pflag = cp_rflag = 1;
break;
- case 'd':
- cp_dflag = 1;
+ case 'P':
+ cp_Pflag = 1;
break;
case 'p':
cp_pflag = 1;
diff --git a/fs.h b/fs.h
index 18b7f4d..4d65766 100644
--- a/fs.h
+++ b/fs.h
_AT_@ -1,7 +1,7 @@
/* See LICENSE file for copyright and license details. */
extern int cp_aflag;
-extern int cp_dflag;
extern int cp_fflag;
+extern int cp_Pflag;
extern int cp_pflag;
extern int cp_rflag;
extern int cp_vflag;
diff --git a/libutil/cp.c b/libutil/cp.c
index f274475..d252e52 100644
--- a/libutil/cp.c
+++ b/libutil/cp.c
_AT_@ -16,8 +16,8 @@
#include "../util.h"
int cp_aflag = 0;
-int cp_dflag = 0;
int cp_fflag = 0;
+int cp_Pflag = 0;
int cp_pflag = 0;
int cp_rflag = 0;
int cp_vflag = 0;
_AT_@ -39,14 +39,14 @@ cp(const char *s1, const char *s2)
if (cp_vflag)
printf("'%s' -> '%s'\n", s1, s2);
- r = cp_dflag ? lstat(s1, &st) : stat(s1, &st);
+ r = cp_Pflag ? lstat(s1, &st) : stat(s1, &st);
if (r < 0) {
- weprintf("%s %s:", cp_dflag ? "lstat" : "stat", s1);
+ weprintf("%s %s:", cp_Pflag ? "lstat" : "stat", s1);
cp_status = 1;
return 0;
}
- if (cp_dflag && S_ISLNK(st.st_mode)) {
+ if (S_ISLNK(st.st_mode)) {
if (readlink(s1, buf, sizeof(buf) - 1) >= 0) {
if (cp_fflag)
unlink(s2);
Received on Mon Dec 08 2014 - 11:03:01 CET
This archive was generated by hypermail 2.3.0
: Mon Dec 08 2014 - 11:12:12 CET