]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(do_link): Produce the same sort of one-line output for
authorJim Meyering <jim@meyering.net>
Sun, 9 Jan 2000 08:23:51 +0000 (08:23 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 9 Jan 2000 08:23:51 +0000 (08:23 +0000)
`--backup --verbose' as cp, mv, install.  Before this, the backup
file name wasn't printed at all.

src/ln.c

index 2af9aa7ac6f2e11213eb19fa98e20fecd50de4ba..671016aa76c50f2ccb50f4c296812fe1d1916d71 100644 (file)
--- a/src/ln.c
+++ b/src/ln.c
@@ -1,5 +1,5 @@
 /* `ln' program to create links between files.
-   Copyright (C) 86, 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
+   Copyright (C) 86, 89, 90, 91, 1995-2000 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -151,6 +151,7 @@ do_link (const char *source, const char *dest)
   struct stat dest_stats;
   char *dest_backup = NULL;
   int lstat_status;
+  int backup_succeeded = 0;
 
   /* Use stat here instead of lstat.
      On SVR4, link does not follow symlinks, so this check disallows
@@ -276,6 +277,10 @@ do_link (const char *source, const char *dest)
              else
                dest_backup = NULL;
            }
+         else
+           {
+             backup_succeeded = 1;
+           }
        }
 
       /* Try to unlink DEST even if we may have renamed it.  In some unusual
@@ -295,7 +300,12 @@ do_link (const char *source, const char *dest)
     }
 
   if (verbose)
-    printf (_("create %s %s to %s\n"), link_type_string, dest, source);
+    {
+      printf (_("create %s %s to %s"), link_type_string, dest, source);
+      if (backup_succeeded)
+       printf (_(" (backup: %s)"), dest_backup);
+      putchar ('\n');
+    }
 
   if ((*linkfunc) (source, dest) == 0)
     {