summaryrefslogtreecommitdiff
path: root/src/cp.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-11-23 04:15:35 +0000
committerJim Meyering <jim@meyering.net>1996-11-23 04:15:35 +0000
commit94d1ea4fa98c40599b959e2f606b0468e172f406 (patch)
tree13c9f520167395ca069d5a0a44b3f7ffe4a5d38a /src/cp.c
parent9645d076db28caec729019d0aa875624efe161e1 (diff)
downloadcoreutils-94d1ea4fa98c40599b959e2f606b0468e172f406.tar.xz
(copy): With -i and not -f, prompt for any type of
(non-directory) source file before overwriting an existing target. Reported by Mark A. Thomas.
Diffstat (limited to 'src/cp.c')
-rw-r--r--src/cp.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/cp.c b/src/cp.c
index 659369e35..3910f9f6d 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -661,21 +661,22 @@ copy (const char *src_path, const char *dst_path, int new_dst, dev_t device,
return 0;
}
- if (S_ISREG (src_type) && !flag_force)
+ if (!S_ISDIR (src_type) && !flag_force && flag_interactive)
{
- if (flag_interactive)
+ if (euidaccess (dst_path, W_OK) != 0)
{
- if (euidaccess (dst_path, W_OK) != 0)
- fprintf (stderr,
- _("%s: overwrite `%s', overriding mode %04o? "),
- program_name, dst_path,
- (unsigned int) (dst_sb.st_mode & 07777));
- else
- fprintf (stderr, _("%s: overwrite `%s'? "),
- program_name, dst_path);
- if (!yesno ())
- return 0;
+ fprintf (stderr,
+ _("%s: overwrite `%s', overriding mode %04o? "),
+ program_name, dst_path,
+ (unsigned int) (dst_sb.st_mode & 07777));
}
+ else
+ {
+ fprintf (stderr, _("%s: overwrite `%s'? "),
+ program_name, dst_path);
+ }
+ if (!yesno ())
+ return 0;
}
if (backup_type != none && !S_ISDIR (dst_sb.st_mode))