diff options
author | Jim Meyering <jim@meyering.net> | 1998-03-13 23:38:50 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1998-03-13 23:38:50 +0000 |
commit | e558629ce1cd131b6c2ff3f2eea9b23df5681313 (patch) | |
tree | 8c67fceca6304de9a014eb038dfbbdee8c7437e3 /src | |
parent | fefa8511b8a31feaa8b39e4a3c83fdf0d8f938b9 (diff) | |
download | coreutils-e558629ce1cd131b6c2ff3f2eea9b23df5681313.tar.xz |
(do_move): Add ©_into_self arg in call to copy.
Don't remove source directory when copy_into_self is nonzero.
Reported by Arne Henrik Juul.
Diffstat (limited to 'src')
-rw-r--r-- | src/mv.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -272,6 +272,7 @@ do_move (const char *source, const char *dest, const struct cp_options *x) and set errno to EXDEV. */ static int first = 1; + int copy_into_self; if (first) { @@ -281,13 +282,18 @@ do_move (const char *source, const char *dest, const struct cp_options *x) hash_init (INITIAL_HASH_MODULE, INITIAL_ENTRY_TAB_SIZE); } - fail = copy (source, dest, nonexistent_dst, x); + fail = copy (source, dest, nonexistent_dst, x, ©_into_self); if (fail) { /* Restore original destination file DEST if made a backup. */ if (dest_backup && rename (dest_backup, dest)) error (0, errno, _("cannot un-backup `%s'"), dest); } + else if (copy_into_self) + { + /* Do *not* remove SOURCE if it is the same as or a parent of DEST. + Otherwise, mv would be removing the original *and* the copy. */ + } else { struct rm_options rm_options; |