]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsirq: mark --json and --pairs options mutually exclusive
authorSami Kerola <kerolasa@iki.fi>
Fri, 6 Mar 2020 20:14:06 +0000 (20:14 +0000)
committerSami Kerola <kerolasa@iki.fi>
Sat, 7 Mar 2020 06:38:57 +0000 (06:38 +0000)
Before this change --pairs option would always win over --json.  That is
unnecessarily confusing, it is much better to disallow combination that does
not make sense.

Notice that the --noheadings in combination with --json or --pairs will not
cause any effect.  In strictest possible understanding --noheadings should
also be exclusive.  Looking from more relaxed point of view neither --json
nor --pairs has heading, so excluding is not necessary because --noheading
is happening already.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/lsirq.c

index 3d7e26abb590c7ed18a2c0e85a49eda9f8c0a908..33fe48d257c920f4c8e634d6fe30b23a0f99aa8b 100644 (file)
@@ -32,6 +32,7 @@
 #include <libsmartcols.h>
 
 #include "closestream.h"
+#include "optutils.h"
 #include "strutils.h"
 #include "xalloc.h"
 
@@ -91,10 +92,17 @@ int main(int argc, char **argv)
        };
        int c;
        const char *outarg = NULL;
+       static const ul_excl_t excl[] = {       /* rows and cols in ASCII order */
+               {'J', 'P'},
+               {0}
+       };
+       int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
 
        setlocale(LC_ALL, "");
 
        while ((c = getopt_long(argc, argv, "no:s:hJPV", longopts, NULL)) != -1) {
+               err_exclusive_options(c, longopts, excl, excl_st);
+
                switch (c) {
                case 'J':
                        out.json = 1;