Add --no-warn.
This commit is contained in:
parent
b4f92f522d
commit
b60376249e
|
@ -46,7 +46,8 @@ parse_real(args_info *args, int argc, char **argv)
|
||||||
OPT_FILES0,
|
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[] = {
|
static const struct option long_opts[] = {
|
||||||
// Operation mode
|
// Operation mode
|
||||||
|
@ -94,6 +95,7 @@ parse_real(args_info *args, int argc, char **argv)
|
||||||
// Other options
|
// Other options
|
||||||
{ "quiet", no_argument, NULL, 'q' },
|
{ "quiet", no_argument, NULL, 'q' },
|
||||||
{ "verbose", no_argument, NULL, 'v' },
|
{ "verbose", no_argument, NULL, 'v' },
|
||||||
|
{ "no-warn", no_argument, NULL, 'Q' },
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
{ "long-help", no_argument, NULL, 'H' },
|
{ "long-help", no_argument, NULL, 'H' },
|
||||||
{ "version", no_argument, NULL, 'V' },
|
{ "version", no_argument, NULL, 'V' },
|
||||||
|
@ -195,6 +197,10 @@ parse_real(args_info *args, int argc, char **argv)
|
||||||
message_verbosity_decrease();
|
message_verbosity_decrease();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'Q':
|
||||||
|
set_exit_no_warn();
|
||||||
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
opt_mode = MODE_TEST;
|
opt_mode = MODE_TEST;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
/// Exit status to use. This can be changed with set_exit_status().
|
/// Exit status to use. This can be changed with set_exit_status().
|
||||||
static enum exit_status_type exit_status = E_SUCCESS;
|
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
|
extern void
|
||||||
set_exit_status(enum exit_status_type new_status)
|
set_exit_status(enum exit_status_type new_status)
|
||||||
|
@ -30,6 +34,14 @@ set_exit_status(enum exit_status_type new_status)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extern void
|
||||||
|
set_exit_no_warn(void)
|
||||||
|
{
|
||||||
|
no_warn = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
my_exit(enum exit_status_type status)
|
my_exit(enum exit_status_type status)
|
||||||
{
|
{
|
||||||
|
@ -59,6 +71,11 @@ my_exit(enum exit_status_type status)
|
||||||
status = E_ERROR;
|
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.
|
// If we have got a signal, raise it to kill the program.
|
||||||
// Otherwise we just call exit().
|
// Otherwise we just call exit().
|
||||||
signals_exit();
|
signals_exit();
|
||||||
|
|
|
@ -24,6 +24,12 @@ enum exit_status_type {
|
||||||
extern void set_exit_status(enum exit_status_type new_status);
|
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
|
/// Exits the program using the given status. This takes care of closing
|
||||||
/// stdin, stdout, and stderr and catches possible errors. If we had got
|
/// 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
|
/// a signal, this function will raise it so that to the parent process it
|
||||||
|
|
|
@ -1133,6 +1133,10 @@ message_help(bool long_help)
|
||||||
" -q, --quiet suppress warnings; specify twice to suppress errors too\n"
|
" -q, --quiet suppress warnings; specify twice to suppress errors too\n"
|
||||||
" -v, --verbose be verbose; specify twice for even more verbose"));
|
" -v, --verbose be verbose; specify twice for even more verbose"));
|
||||||
|
|
||||||
|
if (long_help)
|
||||||
|
puts(_(
|
||||||
|
" -Q, --no-warn make warnings not affect the exit status"));
|
||||||
|
|
||||||
if (long_help)
|
if (long_help)
|
||||||
puts(_(
|
puts(_(
|
||||||
"\n"
|
"\n"
|
||||||
|
|
Loading…
Reference in New Issue