From: Timo Sirainen Date: Thu, 10 Jun 2021 11:23:46 +0000 (+0300) Subject: doveadm: Add CMD_FLAG_NO_UNORDERED_OPTIONS X-Git-Tag: 2.3.17~313 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=938428f914416713b59ce5af4e8d17a79bf1c0a5;p=thirdparty%2Fdovecot%2Fcore.git doveadm: Add CMD_FLAG_NO_UNORDERED_OPTIONS --- diff --git a/src/doveadm/doveadm-cmd.c b/src/doveadm/doveadm-cmd.c index 13ee93d823..3e1343bef6 100644 --- a/src/doveadm/doveadm-cmd.c +++ b/src/doveadm/doveadm-cmd.c @@ -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; diff --git a/src/doveadm/doveadm-cmd.h b/src/doveadm/doveadm-cmd.h index a8f8ae9bdc..4c3c7c4da5 100644 --- a/src/doveadm/doveadm-cmd.h +++ b/src/doveadm/doveadm-cmd.h @@ -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 {