]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(usage): Don't call close_stdout_status directly,
authorJim Meyering <jim@meyering.net>
Thu, 11 May 2000 07:24:05 +0000 (07:24 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 11 May 2000 07:24:05 +0000 (07:24 +0000)
since that didn't cover --version output.
(main): Instead, call close_stdout_set_status and arrange to
call close_stdout via atexit.

src/printenv.c
src/tty.c

index 6ad9692d3649cd57971d6af3cd0de2ae4f1d3613..1c6c028f0615503ce449bf98e94e633a9321fe6a 100644 (file)
@@ -70,7 +70,6 @@ If no environment VARIABLE specified, print them all.\n\
 "),
              program_name, program_name);
       puts (_("\nReport bugs to <bug-sh-utils@gnu.org>."));
-      close_stdout_status (2);
     }
   exit (status);
 }
@@ -90,6 +89,9 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  close_stdout_set_status (2);
+  atexit (close_stdout);
+
   parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
                      AUTHORS, usage);
 
@@ -133,7 +135,5 @@ main (int argc, char **argv)
       exit_status = (matches != argc - optind);
     }
 
-  close_stdout_status (2);
-
   exit (exit_status);
 }
index 04fce48e8b3079e0c1771b441710233d0958500a..145f46dd0760b2a7a36190b328a02d800a7a9e67 100644 (file)
--- a/src/tty.c
+++ b/src/tty.c
@@ -69,7 +69,6 @@ Print the file name of the terminal connected to standard input.\n\
 "));
       puts (_("\nReport bugs to <bug-sh-utils@gnu.org>."));
     }
-  close_stdout_status (3);
   exit (status);
 }
 
@@ -84,6 +83,9 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  close_stdout_set_status (3);
+  atexit (close_stdout);
+
   silent = 0;
 
   while ((optc = getopt_long (argc, argv, "s", longopts, NULL)) != -1)
@@ -116,8 +118,6 @@ main (int argc, char **argv)
        puts (tty);
       else
        puts (_("not a tty"));
-
-      close_stdout_status (3);
     }
 
   exit (isatty (0) ? 0 : 1);