sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit e14e0beccef66be52166f27979fedc19283d62be
parent 573ef00c91fc70edb76afd72f44b9b7bfffd23ff
Author: Michael Forney <mforney@mforney.org>
Date:   Mon Dec  8 03:25:24 +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).

Diffstat:
cp.1 | 6+++---
cp.c | 6+++---
fs.h | 2+-
libutil/cp.c | 8++++----
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/cp.1 b/cp.1 @@ -8,7 +8,7 @@ cp \- copy files and directories .RI [ name ] .P .B cp -.RB [ \-adpRrv ] +.RB [ \-aPpRrv ] .RI [ file ...] .RI [ directory ] .SH DESCRIPTION @@ -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 @@ -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 @@ -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 @@ -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; @@ -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);