From 445b297360b85c03b4509458f194a0d964c1d71a Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Sun, 1 Sep 2013 17:36:37 -0500 Subject: rc: add support for suppressing error messages Add support for suppressing error messages with --quiet specified twice on the command line. X-Gentoo-Bug: 482396 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=482396 --- src/rc/_usage.c | 15 +++++++++++++++ src/rc/_usage.h | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/rc/_usage.c b/src/rc/_usage.c index 96c2d1a..a95e93f 100644 --- a/src/rc/_usage.c +++ b/src/rc/_usage.c @@ -35,6 +35,21 @@ # define _noreturn #endif +static void set_quiet_options(void) +{ + static int qcount = 0; + + qcount ++; + switch (qcount) { + case 1: + setenv ("EINFO_QUIET", "YES", 1); + break; + case 2: + setenv ("EERROR_QUIET", "YES", 1); + break; + } +} + _noreturn static void show_version(void) { diff --git a/src/rc/_usage.h b/src/rc/_usage.h index 84b66b9..0560e89 100644 --- a/src/rc/_usage.h +++ b/src/rc/_usage.h @@ -38,13 +38,13 @@ "Disable color output", \ "Display software version", \ "Run verbosely", \ - "Run quietly" + "Run quietly (repeat to suppress errors)" #define case_RC_COMMON_getopt_case_C setenv ("EINFO_COLOR", "NO", 1); #define case_RC_COMMON_getopt_case_h usage (EXIT_SUCCESS); #define case_RC_COMMON_getopt_case_V if (argc == 2) show_version(); #define case_RC_COMMON_getopt_case_v setenv ("EINFO_VERBOSE", "YES", 1); -#define case_RC_COMMON_getopt_case_q setenv ("EINFO_QUIET", "YES", 1); +#define case_RC_COMMON_getopt_case_q set_quiet_options(); #define case_RC_COMMON_getopt_default usage (EXIT_FAILURE); #define case_RC_COMMON_GETOPT \ -- cgit v1.2.3