[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ln can't backup directories
From: |
Bert Wesarg |
Subject: |
Re: ln can't backup directories |
Date: |
Sun, 13 Sep 2009 12:49:23 +0200 |
On Fri, Sep 11, 2009 at 16:15, Jim Meyering <address@hidden> wrote:
> cp and mv work the same way: even with --backup, they refuse to move
> aside a destination directory.
Which does not seem to be correct, mv backups target directories:
$ mkdir a b
$ touch c
$ \mv --no-target-directory --backup=numbered b a
$ \mv --no-target-directory --backup=numbered c a
$ \ls
a a.~1~ a.~2~
$
But mv could not be used for the backup() alias:
$ \mv --no-target-directory --backup=numbered a a
mv: `a' and `a' are the same file
$ \mv --no-target-directory --backup=numbered -f a a
mv: `a' and `a' are the same file
> Maybe someone will volunteer to do the work.
>
However, the trivial patch below solves the case for cp and ln and
still passes the test suit:
---8<---
Subject: [PATCH] cp, ln: backup target directories
Signed-off-by: Bert Wesarg <address@hidden>
---
src/copy.c | 2 +-
src/ln.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/copy.c b/src/copy.c
index f3ff5a2..5b8fa2f 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -1434,7 +1434,7 @@ copy_internal (char const *src_name, char const *dst_name,
{
if (S_ISDIR (dst_sb.st_mode))
{
- if (x->move_mode && x->backup_type != no_backups)
+ if (x->backup_type != no_backups)
{
/* Moving a non-directory onto an existing
directory is ok only with --backup. */
diff --git a/src/ln.c b/src/ln.c
index 6a1dc32..50af02d 100644
--- a/src/ln.c
+++ b/src/ln.c
@@ -228,7 +228,7 @@ do_link (const char *source, const char *dest)
if (dest_lstat_ok)
{
- if (S_ISDIR (dest_stats.st_mode))
+ if (S_ISDIR (dest_stats.st_mode) && backup_type == no_backups)
{
error (0, 0, _("%s: cannot overwrite directory"), quote (dest));
return false;