]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Arrange to call close_stdout only upon exit.
authorJim Meyering <jim@meyering.net>
Sat, 13 May 2000 06:49:53 +0000 (06:49 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 13 May 2000 06:49:53 +0000 (06:49 +0000)
19 files changed:
src/chgrp.c
src/chmod.c
src/chown.c
src/cp.c
src/df.c
src/dircolors.c
src/du.c
src/install.c
src/ln.c
src/ls.c
src/mkdir.c
src/mkfifo.c
src/mknod.c
src/mv.c
src/rm.c
src/rmdir.c
src/shred.c
src/sync.c
src/touch.c

index 889b82596c3ee11a2a7c9c816bc7b1dcf0a53e2e..ed629fec3d9196d13ef754ec90eaff15a6f006cd 100644 (file)
@@ -1,5 +1,5 @@
 /* chgrp -- change group ownership of files
-   Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
+   Copyright (C) 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
@@ -356,7 +356,6 @@ Change the group membership of each FILE to GROUP.\n\
       --version          output version information and exit\n\
 "));
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
@@ -373,6 +372,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   recurse = force_silent = 0;
 
   while ((optc = getopt_long (argc, argv, "Rcfhv", long_options, NULL)) != -1)
@@ -434,7 +435,5 @@ main (int argc, char **argv)
   for (; optind < argc; ++optind)
     errors |= change_file_group (1, argv[optind], group);
 
-  if (verbosity != V_off)
-    close_stdout ();
   exit (errors);
 }
index 14ad4d5cd5a65fb6f209419361c7a508ea8d0aff..5d6a9b163fc23351ff0934589eab60064976dac0 100644 (file)
@@ -1,5 +1,5 @@
 /* chmod -- change permission modes of files
-   Copyright (C) 89, 90, 91, 1995-1999 Free Software Foundation, Inc.
+   Copyright (C) 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
@@ -263,7 +263,6 @@ Each MODE is one or more of the letters ugoa, one of the symbols +-= and\n\
 one or more of the letters rwxXstugo.\n\
 "));
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
@@ -285,6 +284,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   recurse = force_silent = 0;
 
   while (1)
@@ -364,7 +365,5 @@ main (int argc, char **argv)
       errors |= change_file_mode (argv[optind], changes, 1);
     }
 
-  if (verbosity != V_off)
-    close_stdout ();
   exit (errors);
 }
index 11c502515cffd4d26405a4c56def7b230059bcdd..07337f236f431d7f9e91f90a42313cef24c898a3 100644 (file)
@@ -340,7 +340,6 @@ to login group if implied by a `:'.  OWNER and GROUP may be numeric as well\n\
 as symbolic.\n\
 "));
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
@@ -361,6 +360,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   recurse = force_silent = 0;
 
   while ((optc = getopt_long (argc, argv, "Rcfhv", long_options, NULL)) != -1)
@@ -441,7 +442,5 @@ main (int argc, char **argv)
                                   old_user, old_group);
     }
 
-  if (verbosity != V_off)
-    close_stdout ();
   exit (errors);
 }
index b39db1da60f7db006acc93490604857a1276a719..e4565d320294281f75056b97f950c589b6937897 100644 (file)
--- a/src/cp.c
+++ b/src/cp.c
@@ -201,7 +201,6 @@ options are given and SOURCE and DEST are the same name for an existing,\n\
 regular file.\n\
 "));
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
@@ -683,6 +682,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   cp_option_init (&x);
 
   /* FIXME: consider not calling getenv for SIMPLE_BACKUP_SUFFIX unless
@@ -835,7 +836,5 @@ main (int argc, char **argv)
 
   exit_status |= do_copy (argc - optind, argv + optind, target_directory, &x);
 
-  if (x.verbose)
-    close_stdout ();
   exit (exit_status);
 }
index 794e12b5ce95173e2b9d149debd63ae5e1d96be1..e3a074362f13484c110b7da84f2763f3c0787985 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -752,7 +752,6 @@ or all filesystems by default.\n\
       --version         output version information and exit\n\
 "));
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
@@ -769,6 +768,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   fs_select_list = NULL;
   fs_exclude_list = NULL;
   inode_format = 0;
@@ -932,6 +933,5 @@ main (int argc, char **argv)
          show_entry (argv[i], &stats[i - optind]);
     }
 
-  close_stdout ();
   exit (exit_status);
 }
index c093885fb1697fec6c6090c25c121618b0e2feb0..06c6050b2f19ae5d42caa74f030d0104c0473b0e 100644 (file)
@@ -115,7 +115,6 @@ file types and extensions.  Otherwise, a precompiled database is used.\n\
 For details on the format of these files, run `dircolors --print-database'.\n\
 "));
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
 
   exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
@@ -429,6 +428,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   while ((optc = getopt_long (argc, argv, "bcp", long_options, NULL)) != -1)
     switch (optc)
       {
@@ -530,7 +531,6 @@ dircolors' internal database"));
        }
     }
 
-  close_stdout ();
 
   if (have_read_stdin && fclose (stdin) == EOF)
     error (EXIT_FAILURE, errno, _("standard input"));
index 5729e9424f164dc9551492394171c2dd82f8a459..6c6e451c35e96e8bef65bba033af695407e3c07b 100644 (file)
--- a/src/du.c
+++ b/src/du.c
@@ -227,7 +227,6 @@ Summarize disk usage of each FILE, recursively for directories.\n\
       --version         output version information and exit\n\
 "));
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
@@ -656,6 +655,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   exclude = new_exclude ();
   xstat = lstat;
 
@@ -783,6 +784,5 @@ main (int argc, char **argv)
 
   du_files (optind == argc ? cwd_only : argv + optind);
 
-  close_stdout ();
   exit (exit_status);
 }
index b34909b76f167a7301215b96fe5ebf528261b1d9..6f0f3d15cc661694c0ce03f9ea06f7667265e7c6 100644 (file)
@@ -238,6 +238,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   cp_option_init (&x);
 
   owner_name = NULL;
@@ -380,8 +382,6 @@ is not a directory"),
        }
     }
 
-  if (x.verbose)
-    close_stdout ();
   exit (errors);
 }
 
@@ -674,7 +674,6 @@ the VERSION_CONTROL environment variable.  Here are the values:\n\
   simple, never   always make simple backups\n\
 "));
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
index 741fe277f9f6304f0b5912a077022506a71b52f9..e89a38c1bd564e7743cc425add4866fa9dacbbd6 100644 (file)
--- a/src/ln.c
+++ b/src/ln.c
@@ -372,7 +372,6 @@ the VERSION_CONTROL environment variable.  Here are the values:\n\
   simple, never   always make simple backups\n\
 "));
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
@@ -396,6 +395,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   /* FIXME: consider not calling getenv for SIMPLE_BACKUP_SUFFIX unless
      we'll actually use backup_suffix_string.  */
   backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
@@ -560,7 +561,5 @@ main (int argc, char **argv)
       errors = do_link (source, new_dest);
     }
 
-  if (verbose)
-    close_stdout ();
   exit (errors != 0);
 }
index 5728fd1b4715ea68dcbe855fff5650e118daacea..1364abebd9b4a5b5b764d227c304d790a017842d 100644 (file)
--- a/src/ls.c
+++ b/src/ls.c
@@ -774,6 +774,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
 #define N_ENTRIES(Array) (sizeof Array / sizeof *(Array))
   assert (N_ENTRIES (color_indicator) + 1 == N_ENTRIES (indicator_name));
 
@@ -873,7 +875,6 @@ main (int argc, char **argv)
       put_indicator (&color_indicator[C_RIGHT]);
     }
 
-  close_stdout ();
   exit (exit_status);
 }
 
@@ -3002,7 +3003,6 @@ optional WHEN argument is equivalent to using --color=always.  With\n\
 to a terminal (tty).\n\
 "));
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
index 233827d8cf25b576be425b9395712d3b0dfda063..5964ac4f1fc83b4531c9b31da9400af54ac66f57 100644 (file)
@@ -71,7 +71,6 @@ Create the DIRECTORY(ies), if they do not already exist.\n\
       --version     output version information and exit\n\
 "));
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
@@ -91,6 +90,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   create_parents = 0;
 
   while ((optc = getopt_long (argc, argv, "pm:", longopts, NULL)) != -1)
index fea25f330e976e9e98606c73f5dcb24e6b008335..d396a8269a444ff57e6d72c6c5cbd2ef3712b57a 100644 (file)
@@ -65,7 +65,6 @@ Create named pipes (FIFOs) with the given NAMEs.\n\
       --version     output version information and exit\n\
 "));
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
@@ -85,6 +84,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   symbolic_mode = NULL;
 
 #ifndef S_ISFIFO
index 13cb1c58146b0bc4713348fd285a58e48e2174e2..1c5706b7feff186361a91977554ec8ca4de6bd07 100644 (file)
@@ -76,7 +76,6 @@ MAJOR MINOR are forbidden for TYPE p, mandatory otherwise.  TYPE may be:\n\
   p      create a FIFO\n\
 "));
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
@@ -97,6 +96,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   symbolic_mode = NULL;
 
   while ((optc = getopt_long (argc, argv, "m:", longopts, NULL)) != -1)
index b9f0570426dbe4c2dc1a96575c0d08c1db36c867..796a9ebce36a2b42a109b67a8376717d3ddd6c1e 100644 (file)
--- a/src/mv.c
+++ b/src/mv.c
@@ -379,7 +379,6 @@ the VERSION_CONTROL environment variable.  Here are the values:\n\
   simple, never   always make simple backups\n\
 "));
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
@@ -404,6 +403,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   cp_option_init (&x);
 
   /* FIXME: consider not calling getenv for SIMPLE_BACKUP_SUFFIX unless
@@ -522,7 +523,5 @@ main (int argc, char **argv)
       errors |= movefile (file[i], target_directory, dest_is_dir, &x);
   }
 
-  if (x.verbose)
-    close_stdout ();
   exit (errors);
 }
index 92684b4852fea3241d1e88ddf4bb66a58ea53138..8d80df86bc2158755f009691c2c7096ed4fda2bf 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -104,7 +104,6 @@ use one of these commands:\n\
 "),
              program_name, program_name);
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
@@ -132,6 +131,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   rm_option_init (&x);
 
   while ((c = getopt_long (argc, argv, "dfirvR", long_opts, NULL)) != -1)
@@ -195,7 +196,5 @@ main (int argc, char **argv)
 
   remove_fini ();
 
-  if (x.verbose)
-    close_stdout ();
   exit (fail);
 }
index f4a8a3d6769bf7761ea2eee678a9489ed4189d70..8bd9217168282de0b11f0611ce152d6a98dae623 100644 (file)
@@ -157,7 +157,6 @@ Remove the DIRECTORY(ies), if they are empty.\n\
       --version   output version information and exit\n\
 "));
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
@@ -173,6 +172,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   empty_paths = 0;
 
   while ((optc = getopt_long (argc, argv, "p", longopts, NULL)) != -1)
index fd04c2c14eabaaf9950444e950256c0c17309975..365d7c5f103c25eb13f49d63ca21cb7957e585e0 100644 (file)
@@ -477,7 +477,6 @@ Delete a file securely, first overwriting it to hide its contents.\n\
 \n\
 FIXME maybe add more discussion here?"), DEFAULT_PASSES);
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
@@ -1715,6 +1714,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   isaac_seed (&s);
 
   memset (&flags, 0, sizeof flags);
@@ -1813,8 +1814,6 @@ main (int argc, char **argv)
   /* Just on general principles, wipe s. */
   memset (&s, 0, sizeof s);
 
-  close_stdout ();
-
   exit (err);
 }
 /*
index b2c24824a7a3e9ff61ac8777544b4f1bbb8ae108..63e83b95d728989cc26bf260c7fce91aa0f666f1 100644 (file)
@@ -49,7 +49,6 @@ Force changed blocks to disk, update the super block.\n\
   --version   output version information and exit\n\
 "));
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
@@ -62,6 +61,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
                      AUTHORS, usage);
 
index 5045790af9b421052ff021d804d2618a62c803f0..7d017a5b8822fb175acceded1f87e903f439079f 100644 (file)
@@ -231,7 +231,6 @@ Note that the three time-date formats recognized for the -d and -t options\n\
 and for the obsolescent argument are all different.\n\
 "));
       puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
-      close_stdout ();
     }
   exit (status);
 }
@@ -248,6 +247,8 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  atexit (close_stdout);
+
   change_times = no_create = use_ref = posix_date = flexible_date = 0;
   newtime = (time_t) -1;