X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Ftar.c;h=279e1f8fda1555e06fc91ba469d31f862d940e9d;hb=108edf3692a5ac087267dfce778552427143251f;hp=c8eeaa4fb84c7393bd4a4f736ab537475fcc5385;hpb=78b078b455b834695ebd3104ec3dbe8a4ac9f3a3;p=chaz%2Ftar diff --git a/src/tar.c b/src/tar.c index c8eeaa4..279e1f8 100644 --- a/src/tar.c +++ b/src/tar.c @@ -23,6 +23,7 @@ #include #include +#include #include #if ! defined SIGCHLD && defined SIGCLD @@ -37,6 +38,8 @@ #include "common.h" #include +#include +#include #include #include #include @@ -233,7 +236,7 @@ tar_set_quoting_style (char *arg) return; } FATAL_ERROR ((0, 0, - _("Unknown quoting style `%s'. Try `%s --quoting-style=help' to get a list."), arg)); + _("Unknown quoting style `%s'. Try `%s --quoting-style=help' to get a list."), arg, program_invocation_short_name)); } @@ -1441,7 +1444,8 @@ parse_opt (int key, char *arg, struct argp_state *state) case SHOW_DEFAULTS_OPTION: show_default_settings (stdout); - exit(0); + close_stdout (); + exit (0); case STRIP_COMPONENTS_OPTION: { @@ -1605,16 +1609,18 @@ parse_opt (int key, char *arg, struct argp_state *state) fprintf (state->out_stream, "\n"); fprintf (state->out_stream, _("Report bugs to %s.\n"), argp_program_bug_address); + close_stdout (); exit (0); case USAGE_OPTION: - argp_state_help (state, state->out_stream, - ARGP_HELP_USAGE | ARGP_HELP_EXIT_OK); - break; + argp_state_help (state, state->out_stream, ARGP_HELP_USAGE); + close_stdout (); + exit (0); case VERSION_OPTION: version_etc (state->out_stream, "tar", PACKAGE_NAME, VERSION, "John Gilmore", "Jay Fenlason", (char *) NULL); + close_stdout (); exit (0); case HANG_OPTION: @@ -1643,6 +1649,7 @@ void usage (int status) { argp_help (&argp, stderr, ARGP_HELP_SEE, (char*) program_name); + close_stdout (); exit (status); } @@ -1753,7 +1760,7 @@ decode_options (int argc, char **argv) if (argp_parse (&argp, argc, argv, ARGP_IN_ORDER|ARGP_NO_HELP, &index, &args)) - exit (1); + exit (TAREXIT_FAILURE); /* Special handling for 'o' option: @@ -2003,6 +2010,7 @@ main (int argc, char **argv) bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); + exit_failure = TAREXIT_FAILURE; exit_status = TAREXIT_SUCCESS; filename_terminator = '\n'; set_quoting_style (0, DEFAULT_QUOTING_STYLE); @@ -2089,8 +2097,9 @@ main (int argc, char **argv) free (archive_name_array); name_term (); - if (stdlis != stderr && (ferror (stdlis) || fclose (stdlis) != 0)) - FATAL_ERROR ((0, 0, _("Error in writing to standard output"))); + if (stdlis == stdout) + close_stdout (); + if (exit_status == TAREXIT_FAILURE) error (0, 0, _("Error exit delayed from previous errors")); if (ferror (stderr) || fclose (stderr) != 0)