]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
uuidgen: mark some options mutually exclusive
authorKarel Zak <kzak@redhat.com>
Wed, 23 Aug 2023 09:36:45 +0000 (11:36 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 28 Aug 2023 09:26:23 +0000 (11:26 +0200)
* types cannot be mixed (--time, --random, --md5 and --sha1)
* --count makes sense only for --time and --random
* --name and --namespace makes sense only for --md5 and --sha1

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/uuidgen.c

index 5af35ff96d2a2fc424c923a960429518e7409ea4..ee1235d32f5adcbb6a4f7d4ea42e956f863ffef2 100644 (file)
@@ -18,6 +18,7 @@
 #include "c.h"
 #include "closestream.h"
 #include "strutils.h"
+#include "optutils.h"
 
 static void __attribute__((__noreturn__)) usage(void)
 {
@@ -106,12 +107,24 @@ main (int argc, char *argv[])
                {NULL, 0, NULL, 0}
        };
 
+       static const ul_excl_t excl[] = {
+               { 'C', 'm', 's' },
+               { 'N', 'r', 't' },
+               { 'm', 'r', 's', 't' },
+               { 'n', 'r', 't' },
+               { 0 }
+       };
+       int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
+
        setlocale(LC_ALL, "");
        bindtextdomain(PACKAGE, LOCALEDIR);
        textdomain(PACKAGE);
        close_stdout_atexit();
 
        while ((c = getopt_long(argc, argv, "C:rtVhn:N:msx", longopts, NULL)) != -1) {
+
+               err_exclusive_options(c, longopts, excl, excl_st);
+
                switch (c) {
                case 't':
                        do_type = UUID_TYPE_DCE_TIME;