aboutsummaryrefslogtreecommitdiff
path: root/src/xz
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2009-05-22 14:43:00 +0300
committerLasse Collin <lasse.collin@tukaani.org>2009-05-22 14:43:00 +0300
commitb60376249e0c586910c4121fab4f791820cc1289 (patch)
treea05903c27ddb37000c1eafe453189acf13eb4153 /src/xz
parentFix a comment. (diff)
downloadxz-b60376249e0c586910c4121fab4f791820cc1289.tar.xz
Add --no-warn.
Diffstat (limited to 'src/xz')
-rw-r--r--src/xz/args.c8
-rw-r--r--src/xz/main.c17
-rw-r--r--src/xz/main.h6
-rw-r--r--src/xz/message.c4
4 files changed, 34 insertions, 1 deletions
diff --git a/src/xz/args.c b/src/xz/args.c
index 32ab7785..1ee9a232 100644
--- a/src/xz/args.c
+++ b/src/xz/args.c
@@ -46,7 +46,8 @@ parse_real(args_info *args, int argc, char **argv)
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
@@ -94,6 +95,7 @@ parse_real(args_info *args, int argc, char **argv)
// 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' },
@@ -195,6 +197,10 @@ parse_real(args_info *args, int argc, char **argv)
message_verbosity_decrease();
break;
+ case 'Q':
+ set_exit_no_warn();
+ break;
+
case 't':
opt_mode = MODE_TEST;
break;
diff --git a/src/xz/main.c b/src/xz/main.c
index 0afd9ff7..8a6cde63 100644
--- a/src/xz/main.c
+++ b/src/xz/main.c
@@ -17,6 +17,10 @@
/// 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)
@@ -31,6 +35,14 @@ 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
@@ -59,6 +71,11 @@ my_exit(enum exit_status_type status)
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();
diff --git a/src/xz/main.h b/src/xz/main.h
index 2e35a438..8fd92393 100644
--- a/src/xz/main.h
+++ b/src/xz/main.h
@@ -24,6 +24,12 @@ enum exit_status_type {
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
diff --git a/src/xz/message.c b/src/xz/message.c
index 9e1ee2f6..7598adce 100644
--- a/src/xz/message.c
+++ b/src/xz/message.c
@@ -1135,6 +1135,10 @@ message_help(bool long_help)
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"));