Fix: Error out when passing an argument to long option that takes no argument
[argpar.git] / argpar / argpar.c
index 13f66812894037b669924eb4446fd3f5472e464b..b110f18a90e2432a7f9469b71851af90e834aa2c 100644 (file)
@@ -453,6 +453,15 @@ enum parse_orig_arg_opt_ret parse_long_opt(const char * const long_opt_arg,
                        opt_arg = next_orig_arg;
                        *used_next_orig_arg = true;
                }
+       } else if (eq_pos) {
+               /*
+                * Unexpected `--opt=arg` style for a long option which
+                * doesn't accept an argument.
+                */
+               argpar_string_append_printf(&parse_ret->error,
+                       "Unexpected argument for option `--%s`",
+                       long_opt_name);
+               goto error;
        }
 
        /* Create and append option argument */
This page took 0.021905 seconds and 4 git commands to generate.