summaryrefslogtreecommitdiffstats
path: root/bin/cp
diff options
context:
space:
mode:
authorwosch <wosch@FreeBSD.org>1996-02-19 00:44:19 +0000
committerwosch <wosch@FreeBSD.org>1996-02-19 00:44:19 +0000
commitbaaea7f3b7d27651092bf272882cd88a4d54027e (patch)
tree9b8f8df0eb9caf897a1cbf95bc707616786a4937 /bin/cp
parent961eb1cd883594725b9482b6df04576a582d42c5 (diff)
downloadFreeBSD-src-baaea7f3b7d27651092bf272882cd88a4d54027e.zip
FreeBSD-src-baaea7f3b7d27651092bf272882cd88a4d54027e.tar.gz
delete my last commit
Submitted by: pst, ache
Diffstat (limited to 'bin/cp')
-rw-r--r--bin/cp/cp.121
-rw-r--r--bin/cp/cp.c9
-rw-r--r--bin/cp/extern.h2
-rw-r--r--bin/cp/utils.c17
4 files changed, 14 insertions, 35 deletions
diff --git a/bin/cp/cp.1 b/bin/cp/cp.1
index 4841e41..fad0c0a 100644
--- a/bin/cp/cp.1
+++ b/bin/cp/cp.1
@@ -47,16 +47,14 @@
.Fl R
.Op Fl H | Fl L | Fl P
.Oc
-.Op Fl f | i
-.Op Fl p
+.Op Fl fip
.Ar source_file target_file
.Nm cp
.Oo
.Fl R
.Op Fl H | Fl L | Fl P
.Oc
-.Op Fl f | i
-.Op Fl p
+.Op Fl fip
.Ar source_file ... target_directory
.Sh DESCRIPTION
In the first synopsis form, the
@@ -107,25 +105,18 @@ For each existing destination pathname, remove it and
create a new file, without prompting for confirmation
regardless of its permissions.
(The
-.Fl f
-option overrides any previous
.Fl i
-options.)
+option is ignored if the
+.Fl f
+option is specified.)
.It Fl i
Causes
.Nm cp
to write a prompt to the standard error output before copying a file
that would overwrite an existing file.
If the response from the standard input begins with the character
-.Sq Li y
-or
-.Sq Li Y ,
+.Sq Li y ,
the file copy is attempted.
-(The
-.Fl i
-option overrides any previous
-.Fl f
-options.)
.It Fl p
Causes
.Nm cp
diff --git a/bin/cp/cp.c b/bin/cp/cp.c
index b668d75..cfbcd56 100644
--- a/bin/cp/cp.c
+++ b/bin/cp/cp.c
@@ -86,7 +86,7 @@ static char sccsid[] = "@(#)cp.c 8.2 (Berkeley) 4/1/94";
PATH_T to = { to.p_path, "" };
uid_t myuid;
-int Rflag, iflag, pflag, rflag, fflag;
+int Rflag, iflag, pflag, rflag;
int myumask;
enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
@@ -105,8 +105,7 @@ main(argc, argv)
char *target;
Hflag = Lflag = Pflag = Rflag = 0;
- fflag = iflag = rflag = pflag = 0;
- while ((ch = getopt(argc, argv, "HLPRfipr?")) != EOF)
+ while ((ch = getopt(argc, argv, "HLPRfipr")) != EOF)
switch (ch) {
case 'H':
Hflag = 1;
@@ -125,11 +124,9 @@ main(argc, argv)
break;
case 'f':
iflag = 0;
- fflag = 1;
break;
case 'i':
- iflag = isatty(STDIN_FILENO);
- fflag = 0;
+ iflag = isatty(fileno(stdin));
break;
case 'p':
pflag = 1;
diff --git a/bin/cp/extern.h b/bin/cp/extern.h
index 6ca9910..d97d76aa 100644
--- a/bin/cp/extern.h
+++ b/bin/cp/extern.h
@@ -42,7 +42,7 @@ typedef struct {
extern PATH_T to;
extern uid_t myuid;
-extern int iflag, pflag, fflag, myumask;
+extern int iflag, pflag, myumask;
#include <sys/cdefs.h>
diff --git a/bin/cp/utils.c b/bin/cp/utils.c
index ca7017c..0aa480d 100644
--- a/bin/cp/utils.c
+++ b/bin/cp/utils.c
@@ -86,21 +86,12 @@ copy_file(entp, dne)
checkch = ch = getchar();
while (ch != '\n' && ch != EOF)
ch = getchar();
- if (checkch != 'y' && checkch != 'Y') {
+ if (checkch != 'y') {
(void)close(from_fd);
return (0);
}
}
-
- if (fflag) {
- /* remove existing destination file name,
- * create a new file */
- (void)unlink(to.p_path);
- to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT,
- fs->st_mode & ~(S_ISUID | S_ISGID));
- } else
- /* overwrite existing destination file name */
- to_fd = open(to.p_path, O_WRONLY | O_TRUNC, 0);
+ to_fd = open(to.p_path, O_WRONLY | O_TRUNC, 0);
} else
to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT,
fs->st_mode & ~(S_ISUID | S_ISGID));
@@ -290,7 +281,7 @@ void
usage()
{
(void)fprintf(stderr, "%s\n%s\n",
-"usage: cp [-R [-H | -L | -P] [-f | -i] [-p] src target",
-" cp [-R [-H | -L | -P] [-f | -i] [-p] src1 ... srcN directory");
+"usage: cp [-R [-H | -L | -P] [-fip] src target",
+" cp [-R [-H | -L | -P] [-fip] src1 ... srcN directory");
exit(1);
}
OpenPOWER on IntegriCloud