#include <system.h>
#include <fnmatch.h>
+#include <getline.h>
#include <argp.h>
+#include <argp-namefrob.h>
#include <signal.h>
#if ! defined SIGCHLD && defined SIGCLD
#include "common.h"
#include <argmatch.h>
+#include <closeout.h>
+#include <exitfail.h>
#include <getdate.h>
#include <localedir.h>
#include <rmt.h>
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));
}
\f
case SHOW_DEFAULTS_OPTION:
show_default_settings (stdout);
- exit(0);
+ close_stdout ();
+ exit (0);
case STRIP_COMPONENTS_OPTION:
{
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:
usage (int status)
{
argp_help (&argp, stderr, ARGP_HELP_SEE, (char*) program_name);
+ close_stdout ();
exit (status);
}
if (argp_parse (&argp, argc, argv, ARGP_IN_ORDER|ARGP_NO_HELP,
&index, &args))
- exit (1);
+ exit (TAREXIT_FAILURE);
/* Special handling for 'o' option:
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ exit_failure = TAREXIT_FAILURE;
exit_status = TAREXIT_SUCCESS;
filename_terminator = '\n';
set_quoting_style (0, DEFAULT_QUOTING_STYLE);
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)