Allow --backtrace-limit option to appear in RUBYOPT

There’s no reason to prevent RUBYOPT from controlling the backtrace
limit. In fact, Matz said [0] he was expecting this to be possible.

[0] https://bugs.ruby-lang.org/issues/8661#note-27
This commit is contained in:
Tom Stuart 2023-07-01 15:15:09 +01:00 committed by Nobuyoshi Nakada
parent e5825de7c9
commit 72a3bb7edc

2
ruby.c
View File

@ -1446,7 +1446,7 @@ proc_long_options(ruby_cmdline_options_t *opt, const char *s, long argc, char **
opt->dump |= DUMP_BIT(help);
return 0;
}
else if (is_option_with_arg("backtrace-limit", Qfalse, Qfalse)) {
else if (is_option_with_arg("backtrace-limit", Qfalse, Qtrue)) {
char *e;
long n = strtol(s, &e, 10);
if (errno == ERANGE || n < 0 || *e) rb_raise(rb_eRuntimeError, "wrong limit for backtrace length");