The embedded cpmain() will never have _any_ flags set,
as mv.c calls it as

        argv[0] = from;
        argv[1] = to;
        argv[2] = NULL;
        cpmain(2, argv);

There is probably more code that could be romoved
form the embedded cp.c, along the lines of tedu's recent
cleanup of the embedded rm.c

        Jan


Index: cp.c
===================================================================
RCS file: /cvs/src/bin/mv/cp.c,v
retrieving revision 1.7
diff -u -p -r1.7 cp.c
--- cp.c        27 Dec 2015 01:25:57 -0000      1.7
+++ cp.c        10 Oct 2016 19:27:02 -0000
@@ -84,7 +84,6 @@ static int     setfile(struct stat *, in
 extern char *__progname;
 
 static uid_t myuid;
-static int fflag, iflag;
 static mode_t myumask;
 
 enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
@@ -463,13 +462,6 @@ copy_file(FTSENT *entp, int dne)
        fs = entp->fts_statp;
 
        /*
-        * In -f (force) mode, we always unlink the destination first
-        * if it exists.  Note that -i and -f are mutually exclusive.
-        */
-       if (!dne && fflag)
-               (void)unlink(to.p_path);
-
-       /*
         * If the file exists and we're interactive, verify with the user.
         * If the file DNE, set the mode to be the from file, minus setuid
         * bits, modified by the umask; arguably wrong, but it makes copying
@@ -477,17 +469,7 @@ copy_file(FTSENT *entp, int dne)
         * other choice is 666 or'ed with the execute bits on the from file
         * modified by the umask.)
         */
-       if (!dne && !fflag) {
-               if (iflag) {
-                       (void)fprintf(stderr, "overwrite %s? ", to.p_path);
-                       checkch = ch = getchar();
-                       while (ch != '\n' && ch != EOF)
-                               ch = getchar();
-                       if (checkch != 'y' && checkch != 'Y') {
-                               (void)close(from_fd);
-                               return (0);
-                       }
-               }
+       if (!dne) {
                to_fd = open(to.p_path, O_WRONLY | O_TRUNC, 0);
        } else
                to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT,

Reply via email to