don't ask about access modes, if already asked for i flag.
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 22 Jan 1988 08:54:32 +0000 (00:54 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 22 Jan 1988 08:54:32 +0000 (00:54 -0800)
SCCS-vsn: bin/mv/mv.c 5.6

usr/src/bin/mv/mv.c

index b3f0f75..e15f922 100644 (file)
@@ -11,7 +11,7 @@ char copyright[] =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char sccsid[] = "@(#)mv.c       5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)mv.c       5.6 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -20,6 +20,7 @@ static char sccsid[] = "@(#)mv.c      5.5 (Berkeley) %G%";
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/time.h>
+#include <sys/file.h>
 
 #include <stdio.h>
 #include <sys/dir.h>
 
 #include <stdio.h>
 #include <sys/dir.h>
@@ -131,14 +132,15 @@ move(source, target)
                        error("%s and %s are identical", source, target);
                        return (1);
                }
                        error("%s and %s are identical", source, target);
                        return (1);
                }
-               if (iflag && !fflag && isatty(fileno(stdin)) &&
-                   query("remove %s? ", target) == 0)
-                       return (1);
-               if (access(target, 2) < 0 && !fflag && isatty(fileno(stdin))) {
-                       if (query("override protection %o for %s? ",
-                         s2.st_mode & MODEBITS, target) == 0)
+               if (!fflag && isatty(fileno(stdin)))
+                       if (iflag) {
+                               if (!query("remove %s? ", target))
+                                       return (1);
+                       }
+                       else if (access(target, W_OK) < 0 &&
+                           !query("override protection %o for %s? ",
+                           s2.st_mode & MODEBITS, target))
                                return (1);
                                return (1);
-               }
        }
        if (rename(source, target) >= 0)
                return (0);
        }
        if (rename(source, target) >= 0)
                return (0);