]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm: Add CMD_FLAG_NO_UNORDERED_OPTIONS
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 10 Jun 2021 11:23:46 +0000 (14:23 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 21 Jul 2021 09:03:09 +0000 (09:03 +0000)
src/doveadm/doveadm-cmd.c
src/doveadm/doveadm-cmd.h

index 13ee93d823d7cf66f3b1fb02daada06f45dba653..3e1343bef6191ed1a65f30f60fe52e33317d229d 100644 (file)
@@ -522,6 +522,8 @@ doveadm_cmd_process_options(int argc, const char *const argv[],
        p_array_init(&opts, pool, 4);
 
        // build parameters
+       if ((cctx->cmd->flags & CMD_FLAG_NO_UNORDERED_OPTIONS) != 0)
+               str_append_c(optbuf, '+');
        doveadm_build_options(cctx->cmd->parameters, optbuf, &opts);
 
        unsigned int pargc;
index a8f8ae9bdcbdbc2cd69833cf0550622ed9e9fc18..4c3c7c4da5939515e64d559900c15901ef956193 100644 (file)
@@ -34,6 +34,10 @@ typedef enum {
        CMD_FLAG_NO_PRINT               = 0x2,
        /* Don't parse any -options for the command. */
        CMD_FLAG_NO_OPTIONS             = 0x4,
+       /* Prevent GNU getopt() from finding options after the first
+          non-option is seen (e.g. "-1 arg -2" would parse -1 but not -2
+          as option). */
+       CMD_FLAG_NO_UNORDERED_OPTIONS   = 0x8,
 } doveadm_cmd_flag_t;
 
 struct doveadm_cmd_param {