clean option state, except for the options that are global. Global options
retain their values and meaning even after --next.
+If the long option name ends with an equals sign (`=`), the argument is the
+text following on its right side. (Added in 8.16.0)
+
The first argument that is exactly two dashes (`--`), marks the end of
options; any argument after the end of options is interpreted as a URL
argument even if it starts with a dash.
return err;
}
+/* the longest command line option, excluding the leading -- */
+#define MAX_OPTION_LEN 26
+
ParameterError getparameter(const char *flag, /* f or -long-flag */
const char *nextarg, /* NULL if unset */
bool *usedarg, /* set to TRUE if the arg
bool toggle = TRUE; /* how to switch boolean options, on or off. Controlled
by using --OPTION or --no-OPTION */
bool nextalloc = FALSE; /* if nextarg is allocated */
+ bool consumearg = TRUE; /* the argument comes separate */
const struct LongShort *a = NULL;
struct GlobalConfig *global = config->global;
verbose_nopts = 0; /* options processed in `flag`*/
const char *word = ('-' == flag[0]) ? flag + 2 : flag;
bool noflagged = FALSE;
bool expand = FALSE;
+ const char *p;
+ struct Curl_str out;
if(!strncmp(word, "no-", 3)) {
/* disable this option but ignore the "no-" part when looking for it */
expand = TRUE;
}
- a = findlongopt(word);
+ p = word;
+ /* is there an '=' ? */
+ if(!curlx_str_until(&p, &out, MAX_OPTION_LEN, '=') &&
+ !curlx_str_single(&p, '=') ) {
+ /* there's an equal sign */
+ char tempword[MAX_OPTION_LEN + 1];
+ memcpy(tempword, curlx_str(&out), curlx_strlen(&out));
+ tempword[curlx_strlen(&out)] = 0;
+ a = findlongopt(tempword);
+ nextarg = p;
+ consumearg = FALSE; /* it is not separate */
+ }
+ else
+ a = findlongopt(word);
+
if(a) {
longopt = TRUE;
}
break;
}
else {
- *usedarg = TRUE; /* mark it as used */
+ *usedarg = consumearg; /* mark it as used */
}
if(a->desc & ARG_DEPR) {
opt_depr(global, a);