Honor the same option given later

This commit is contained in:
Nobuyoshi Nakada 2023-08-21 17:29:44 +09:00
parent 70e8a08295
commit f714448be7

6
ruby.c
View File

@ -899,6 +899,7 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt)
ruby_features_t feat = opt->features; ruby_features_t feat = opt->features;
ruby_features_t warn = opt->warn; ruby_features_t warn = opt->warn;
long backtrace_length_limit = opt->backtrace_length_limit; long backtrace_length_limit = opt->backtrace_length_limit;
const char *bugreport_path = opt->bugreport_path;
while (ISSPACE(*s)) s++; while (ISSPACE(*s)) s++;
if (!*s) return; if (!*s) return;
@ -953,6 +954,9 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt)
if (BACKTRACE_LENGTH_LIMIT_VALID_P(backtrace_length_limit)) { if (BACKTRACE_LENGTH_LIMIT_VALID_P(backtrace_length_limit)) {
opt->backtrace_length_limit = backtrace_length_limit; opt->backtrace_length_limit = backtrace_length_limit;
} }
if (bugreport_path) {
opt->bugreport_path = bugreport_path;
}
ruby_xfree(ptr); ruby_xfree(ptr);
/* get rid of GC */ /* get rid of GC */
@ -1464,10 +1468,8 @@ proc_long_options(ruby_cmdline_options_t *opt, const char *s, long argc, char **
} }
} }
else if (is_option_with_arg("bugreport-path", true, true)) { else if (is_option_with_arg("bugreport-path", true, true)) {
if (!opt->bugreport_path) {
opt->bugreport_path = s; opt->bugreport_path = s;
} }
}
else { else {
rb_raise(rb_eRuntimeError, rb_raise(rb_eRuntimeError,
"invalid option --%s (-h will show valid options)", s); "invalid option --%s (-h will show valid options)", s);