From 81b16373ae2acf0e585e30b91b0a0dd1ac7883fb Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 13 May 2000 06:49:53 +0000 Subject: [PATCH] Arrange to call close_stdout only upon exit. --- src/chgrp.c | 7 +++---- src/chmod.c | 7 +++---- src/chown.c | 5 ++--- src/cp.c | 5 ++--- src/df.c | 4 ++-- src/dircolors.c | 4 ++-- src/du.c | 4 ++-- src/install.c | 5 ++--- src/ln.c | 5 ++--- src/ls.c | 4 ++-- src/mkdir.c | 3 ++- src/mkfifo.c | 3 ++- src/mknod.c | 3 ++- src/mv.c | 5 ++--- src/rm.c | 5 ++--- src/rmdir.c | 3 ++- src/shred.c | 5 ++--- src/sync.c | 3 ++- src/touch.c | 3 ++- 19 files changed, 40 insertions(+), 43 deletions(-) diff --git a/src/chgrp.c b/src/chgrp.c index 889b825..ed629fe 100644 --- a/src/chgrp.c +++ b/src/chgrp.c @@ -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 .")); - 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); } diff --git a/src/chmod.c b/src/chmod.c index 14ad4d5..5d6a9b1 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -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 .")); - 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); } diff --git a/src/chown.c b/src/chown.c index 11c5025..07337f2 100644 --- a/src/chown.c +++ b/src/chown.c @@ -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 .")); - 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); } diff --git a/src/cp.c b/src/cp.c index b39db1d..e4565d3 100644 --- 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 .")); - 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); } diff --git a/src/df.c b/src/df.c index 794e12b..e3a0743 100644 --- 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 .")); - 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); } diff --git a/src/dircolors.c b/src/dircolors.c index c093885..06c6050 100644 --- a/src/dircolors.c +++ b/src/dircolors.c @@ -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 .")); - 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")); diff --git a/src/du.c b/src/du.c index 5729e94..6c6e451 100644 --- 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 .")); - 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); } diff --git a/src/install.c b/src/install.c index b34909b..6f0f3d1 100644 --- a/src/install.c +++ b/src/install.c @@ -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 .")); - close_stdout (); } exit (status); } diff --git a/src/ln.c b/src/ln.c index 741fe27..e89a38c 100644 --- 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 .")); - 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); } diff --git a/src/ls.c b/src/ls.c index 5728fd1..1364abe 100644 --- 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 .")); - close_stdout (); } exit (status); } diff --git a/src/mkdir.c b/src/mkdir.c index 233827d..5964ac4 100644 --- a/src/mkdir.c +++ b/src/mkdir.c @@ -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 .")); - 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) diff --git a/src/mkfifo.c b/src/mkfifo.c index fea25f3..d396a82 100644 --- a/src/mkfifo.c +++ b/src/mkfifo.c @@ -65,7 +65,6 @@ Create named pipes (FIFOs) with the given NAMEs.\n\ --version output version information and exit\n\ ")); puts (_("\nReport bugs to .")); - 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 diff --git a/src/mknod.c b/src/mknod.c index 13cb1c5..1c5706b 100644 --- a/src/mknod.c +++ b/src/mknod.c @@ -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 .")); - 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) diff --git a/src/mv.c b/src/mv.c index b9f0570..796a9eb 100644 --- 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 .")); - 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); } diff --git a/src/rm.c b/src/rm.c index 92684b4..8d80df8 100644 --- 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 .")); - 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); } diff --git a/src/rmdir.c b/src/rmdir.c index f4a8a3d..8bd9217 100644 --- a/src/rmdir.c +++ b/src/rmdir.c @@ -157,7 +157,6 @@ Remove the DIRECTORY(ies), if they are empty.\n\ --version output version information and exit\n\ ")); puts (_("\nReport bugs to .")); - 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) diff --git a/src/shred.c b/src/shred.c index fd04c2c..365d7c5 100644 --- a/src/shred.c +++ b/src/shred.c @@ -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 .")); - 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); } /* diff --git a/src/sync.c b/src/sync.c index b2c2482..63e83b9 100644 --- a/src/sync.c +++ b/src/sync.c @@ -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 .")); - 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); diff --git a/src/touch.c b/src/touch.c index 5045790..7d017a5 100644 --- a/src/touch.c +++ b/src/touch.c @@ -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 .")); - 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; -- 2.7.4