]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hardlink: remove \r from output
authorKarel Zak <kzak@redhat.com>
Wed, 24 Apr 2019 16:31:08 +0000 (18:31 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 24 Apr 2019 16:31:08 +0000 (18:31 +0200)
* remove \r from internationalized messages
* remove \r from all output to make it easy to use (see for example
  output file from "hardlink -vv --dry-run . &> log")

* remove unnecessary formatting stuff from output, just keep is simple
  and stupid...

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/hardlink.c

index 2a1e216a21737fda2ad565bcc0bdca0ff75f0590..953b3b7f91efc82fc813f3c053cee075592691f7 100644 (file)
@@ -212,7 +212,7 @@ static void process_path(const char *name)
 
                nregfiles++;
                if (verbose > 1)
-                       printf("  %s", name);
+                       printf("%s\n", name);
 
                fd = open(name, O_RDONLY);
                if (fd < 0)
@@ -225,8 +225,6 @@ static void process_path(const char *name)
                }
                if (read(fd, buf, cksumsize) != cksumsize) {
                        close(fd);
-                       if (verbose > 1 && namelen <= PATH_MAX)
-                               printf("\r%*s\r", (int)(namelen + 2), "");
                        return;
                }
                cksumsize = (cksumsize + sizeof(buf[0]) - 1) / sizeof(buf[0]);
@@ -255,8 +253,6 @@ static void process_path(const char *name)
                for (fp2 = fp; fp2 && fp2->cksum == cksum; fp2 = fp2->next) {
                        if (fp2->ino == st.st_ino && fp2->dev == st.st_dev) {
                                close(fd);
-                               if (verbose > 1 && namelen <= PATH_MAX)
-                                       printf("\r%*s\r", (int)(namelen + 2), "");
                                return;
                        }
                }
@@ -349,17 +345,13 @@ static void process_path(const char *name)
                                        /* We actually did not save anything this time, since the link second argument
                                           had some other links as well.  */
                                        if (verbose > 1)
-                                               printf(_("\r%*s\r%s %s to %s\n"),
-                                                       (int)(((namelen > PATH_MAX) ? 0 : namelen) + 2),
-                                                       "",
+                                               printf(_(" %s %s to %s\n"),
                                                        (no_link ? _("Would link") : _("Linked")),
                                                        n1, n2);
                                } else {
                                        nsaved += ((st.st_size + 4095) / 4096) * 4096;
                                        if (verbose > 1)
-                                               printf(_("\r%*s\r%s %s to %s, %s %jd\n"),
-                                                       (int)(((namelen > PATH_MAX) ? 0 : namelen) + 2),
-                                                       "",
+                                               printf(_(" %s %s to %s, %s %jd\n"),
                                                        (no_link ? _("Would link") : _("Linked")),
                                                        n1, n2,
                                                        (no_link ? _("would save") : _("saved")),
@@ -383,8 +375,6 @@ static void process_path(const char *name)
                        fp2->next = hp->chain;
                        hp->chain = fp2;
                }
-               if (verbose > 1 && namelen <= PATH_MAX)
-                       printf("\r%*s\r", (int)(namelen + 2), "");
                return;
        }
 }