]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(head): Call write_header here.
authorJim Meyering <jim@meyering.net>
Mon, 7 Aug 2000 13:27:24 +0000 (13:27 +0000)
committerJim Meyering <jim@meyering.net>
Mon, 7 Aug 2000 13:27:24 +0000 (13:27 +0000)
(head_file): ... not here.

src/head.c

index 30dfd9905333b0d938cd71cd6d0698e622f6ed87..7bc3cad17a4909e6303d36bcefe3d4ec8222da0f 100644 (file)
@@ -175,6 +175,9 @@ head_lines (const char *filename, int fd, uintmax_t lines_to_write)
 static int
 head (const char *filename, int fd, uintmax_t n_units, int count_lines)
 {
+  if (print_headers)
+    write_header (filename);
+
   if (count_lines)
     return head_lines (filename, fd, n_units);
   else
@@ -189,10 +192,7 @@ head_file (const char *filename, uintmax_t n_units, int count_lines)
   if (STREQ (filename, "-"))
     {
       have_read_stdin = 1;
-      filename = _("standard input");
-      if (print_headers)
-       write_header (filename);
-      return head (filename, STDIN_FILENO, n_units, count_lines);
+      return head (_("standard input"), STDIN_FILENO, n_units, count_lines);
     }
   else
     {
@@ -201,8 +201,6 @@ head_file (const char *filename, uintmax_t n_units, int count_lines)
        {
          int errors;
 
-         if (print_headers)
-           write_header (filename);
          errors = head (filename, fd, n_units, count_lines);
          if (close (fd) == 0)
            return errors;