diff mbox series

[03/76] parse-options: allow keep-unknown + stop-at-non-opt combination

Message ID 20190117130615.18732-4-pclouds@gmail.com (mailing list archive)
State New, archived
Headers show
Series Convert diff opt parser to parse_options() | expand

Commit Message

Duy Nguyen Jan. 17, 2019, 1:05 p.m. UTC
These two are orthogonal. One is about unknown _option_ while the
other non-option.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 parse-options.c | 3 ---
 1 file changed, 3 deletions(-)

Comments

Stefan Beller Jan. 17, 2019, 6:33 p.m. UTC | #1
On Thu, Jan 17, 2019 at 5:06 AM Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
>
> These two are orthogonal. One is about unknown _option_ while the
> other non-option.

Though 0d260f9a09 ("parseopt: prevent KEEP_UNKNOWN and
STOP_AT_NON_OPTION from being used together", 2009-03-09)
seemed convincing to have this?

Maybe we only need this BUG in case of !PARSE_OPT_ONE_SHOT?

> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  parse-options.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/parse-options.c b/parse-options.c
> index eb5de0da29..678b263897 100644
> --- a/parse-options.c
> +++ b/parse-options.c
> @@ -427,9 +427,6 @@ void parse_options_start(struct parse_opt_ctx_t *ctx,
>         ctx->prefix = prefix;
>         ctx->cpidx = ((flags & PARSE_OPT_KEEP_ARGV0) != 0);
>         ctx->flags = flags;
> -       if ((flags & PARSE_OPT_KEEP_UNKNOWN) &&
> -           (flags & PARSE_OPT_STOP_AT_NON_OPTION))
> -               BUG("STOP_AT_NON_OPTION and KEEP_UNKNOWN don't go together");
>         if ((flags & PARSE_OPT_ONE_SHOT) &&
>             (flags & PARSE_OPT_KEEP_ARGV0))
>                 BUG("Can't keep argv0 if you don't have it");
> --
> 2.20.0.482.g66447595a7
>
diff mbox series

Patch

diff --git a/parse-options.c b/parse-options.c
index eb5de0da29..678b263897 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -427,9 +427,6 @@  void parse_options_start(struct parse_opt_ctx_t *ctx,
 	ctx->prefix = prefix;
 	ctx->cpidx = ((flags & PARSE_OPT_KEEP_ARGV0) != 0);
 	ctx->flags = flags;
-	if ((flags & PARSE_OPT_KEEP_UNKNOWN) &&
-	    (flags & PARSE_OPT_STOP_AT_NON_OPTION))
-		BUG("STOP_AT_NON_OPTION and KEEP_UNKNOWN don't go together");
 	if ((flags & PARSE_OPT_ONE_SHOT) &&
 	    (flags & PARSE_OPT_KEEP_ARGV0))
 		BUG("Can't keep argv0 if you don't have it");