OPT_FILES0,
};
- static const char short_opts[] = "cC:defF:hHlkM:qrS:tT:vVz0123456789";
+ static const char short_opts[]
+ = "cC:defF:hHlkM:qQrS:tT:vVz0123456789";
static const struct option long_opts[] = {
// Operation mode
// Other options
{ "quiet", no_argument, NULL, 'q' },
{ "verbose", no_argument, NULL, 'v' },
+ { "no-warn", no_argument, NULL, 'Q' },
{ "help", no_argument, NULL, 'h' },
{ "long-help", no_argument, NULL, 'H' },
{ "version", no_argument, NULL, 'V' },
message_verbosity_decrease();
break;
+ case 'Q':
+ set_exit_no_warn();
+ break;
+
case 't':
opt_mode = MODE_TEST;
break;
/// Exit status to use. This can be changed with set_exit_status().
static enum exit_status_type exit_status = E_SUCCESS;
+/// True if --no-warn is specified. When this is true, we don't set
+/// the exit status to E_WARNING when something worth a warning happens.
+static bool no_warn = false;
+
extern void
set_exit_status(enum exit_status_type new_status)
extern void
+set_exit_no_warn(void)
+{
+ no_warn = true;
+ return;
+}
+
+
+extern void
my_exit(enum exit_status_type status)
{
// Close stdout. If something goes wrong, print an error message
status = E_ERROR;
}
+ // Suppress the exit status indicating a warning if --no-warn
+ // was specified.
+ if (status == E_WARNING && no_warn)
+ status = E_SUCCESS;
+
// If we have got a signal, raise it to kill the program.
// Otherwise we just call exit().
signals_exit();
extern void set_exit_status(enum exit_status_type new_status);
+/// Use E_SUCCESS instead of E_WARNING if something worth a warning occurs
+/// but nothing worth an error has occurred. This is called when --no-warn
+/// is specified.
+extern void set_exit_no_warn(void);
+
+
/// Exits the program using the given status. This takes care of closing
/// stdin, stdout, and stderr and catches possible errors. If we had got
/// a signal, this function will raise it so that to the parent process it
if (long_help)
puts(_(
+" -Q, --no-warn make warnings not affect the exit status"));
+
+ if (long_help)
+ puts(_(
"\n"
" -h, --help display the short help (lists only the basic options)\n"
" -H, --long-help display this long help"));