[ruby-core:114064] [Ruby master Feature#19752] Allow `--backtrace-limit` to appear in RUBYOPT

Issue #19752 has been reported by tomstuart (Tom Stuart). ---------------------------------------- Feature #19752: Allow `--backtrace-limit` to appear in RUBYOPT https://bugs.ruby-lang.org/issues/19752 * Author: tomstuart (Tom Stuart) * Status: Open * Priority: Normal ---------------------------------------- The `--backtrace-limit` option was added in #8661 but it is not currently supported in the `RUBYOPT` environment variable, which appears to be a mistake. Unlike other long options which are not allowed in `RUBYOPT` (e.g. `--copyright`, `--version`, `--dump` and `--help`) it does not cause the interpreter to terminate, and cannot cause harm if read from the environment. During the initial discussion about the `--backtrace-limit` feature, Matz [suggested](https://bugs.ruby-lang.org/issues/8661#note-27) that he expected `RUBYOPT` to allow this option. Patch here, which also documents `--backtrace-limit` on Ruby’s `man` page: https://github.com/ruby/ruby/pull/8010 -- https://bugs.ruby-lang.org/

Issue #19752 has been updated by mame (Yusuke Endoh). Status changed from Open to Assigned Assignee set to matz (Yukihiro Matsumoto) The proposed patch includes a change to treat it as unspecified with -1. I would like to get Matz's approval on this. ---------------------------------------- Feature #19752: Allow `--backtrace-limit` to appear in RUBYOPT https://bugs.ruby-lang.org/issues/19752#change-103740 * Author: tomstuart (Tom Stuart) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) ---------------------------------------- The `--backtrace-limit` option was added in #8661 but it is not currently supported in the `RUBYOPT` environment variable, which appears to be a mistake. Unlike other long options which are not allowed in `RUBYOPT` (e.g. `--copyright`, `--version`, `--dump` and `--help`) it does not cause the interpreter to terminate, and cannot cause harm if read from the environment. During the initial discussion about the `--backtrace-limit` feature, Matz [suggested](https://bugs.ruby-lang.org/issues/8661#note-27) that he expected `RUBYOPT` to allow this option. Patch here, which also documents `--backtrace-limit` on Ruby’s `man` page: https://github.com/ruby/ruby/pull/8010 -- https://bugs.ruby-lang.org/

Issue #19752 has been updated by tomstuart (Tom Stuart). My main goal is to allow `RUBYOPT` to support `--backtrace-limit`. I am happy to remove the ability to say `--backtrace-limit=-1` from my patch if it’s undesirable, but since `-1` is already a meaningful value for the backtrace limit, it seems useful and unsurprising to allow it. For example, this makes to make it possible to use `RUBYOPT` to restore the default backtrace limit by saying `RUBYOPT="--backtrace-limit=-1" ruby --backtrace-limit=5`. ---------------------------------------- Feature #19752: Allow `--backtrace-limit` to appear in RUBYOPT https://bugs.ruby-lang.org/issues/19752#change-103794 * Author: tomstuart (Tom Stuart) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) ---------------------------------------- The `--backtrace-limit` option was added in #8661 but it is not currently supported in the `RUBYOPT` environment variable, which appears to be a mistake. Unlike other long options which are not allowed in `RUBYOPT` (e.g. `--copyright`, `--version`, `--dump` and `--help`) it does not cause the interpreter to terminate, and cannot cause harm if read from the environment. During the initial discussion about the `--backtrace-limit` feature, Matz [suggested](https://bugs.ruby-lang.org/issues/8661#note-27) that he expected `RUBYOPT` to allow this option. Patch here, which also documents `--backtrace-limit` on Ruby’s `man` page: https://github.com/ruby/ruby/pull/8010 -- https://bugs.ruby-lang.org/

Issue #19752 has been updated by matz (Yukihiro Matsumoto). Basically accepted, including `--backtrace-limit=-1`. But as far as I understand, command line options are (and should be) higher precedence than `RUBYOPT`. Matz. ---------------------------------------- Feature #19752: Allow `--backtrace-limit` to appear in RUBYOPT https://bugs.ruby-lang.org/issues/19752#change-103832 * Author: tomstuart (Tom Stuart) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) ---------------------------------------- The `--backtrace-limit` option was added in #8661 but it is not currently supported in the `RUBYOPT` environment variable, which appears to be a mistake. Unlike other long options which are not allowed in `RUBYOPT` (e.g. `--copyright`, `--version`, `--dump` and `--help`) it does not cause the interpreter to terminate, and cannot cause harm if read from the environment. During the initial discussion about the `--backtrace-limit` feature, Matz [suggested](https://bugs.ruby-lang.org/issues/8661#note-27) that he expected `RUBYOPT` to allow this option. Patch here, which also documents `--backtrace-limit` on Ruby’s `man` page: https://github.com/ruby/ruby/pull/8010 -- https://bugs.ruby-lang.org/

Issue #19752 has been updated by tomstuart (Tom Stuart). Thank you for accepting! Currently (i.e. on `master` with this patch applied), `--backtrace-limit` in `RUBYOPT` has higher precedence than the command line option: ``` % ruby -v ruby 3.3.0dev (2023-07-13T07:54:27Z backtrace-limit-fi.. b1b0395cd1) [arm64-darwin22] last_commit=Add `--backtrace-limit` option to the man page % RUBYOPT="--backtrace-limit=10" ruby --backtrace-limit=5 -e "puts Thread::Backtrace.limit" 10 ``` Is this a bug? ---------------------------------------- Feature #19752: Allow `--backtrace-limit` to appear in RUBYOPT https://bugs.ruby-lang.org/issues/19752#change-103833 * Author: tomstuart (Tom Stuart) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) ---------------------------------------- The `--backtrace-limit` option was added in #8661 but it is not currently supported in the `RUBYOPT` environment variable, which appears to be a mistake. Unlike other long options which are not allowed in `RUBYOPT` (e.g. `--copyright`, `--version`, `--dump` and `--help`) it does not cause the interpreter to terminate, and cannot cause harm if read from the environment. During the initial discussion about the `--backtrace-limit` feature, Matz [suggested](https://bugs.ruby-lang.org/issues/8661#note-27) that he expected `RUBYOPT` to allow this option. Patch here, which also documents `--backtrace-limit` on Ruby’s `man` page: https://github.com/ruby/ruby/pull/8010 -- https://bugs.ruby-lang.org/

Issue #19752 has been updated by matz (Yukihiro Matsumoto). Yes, it should be fixed. I think @nobu is working on it. Matz. ---------------------------------------- Feature #19752: Allow `--backtrace-limit` to appear in RUBYOPT https://bugs.ruby-lang.org/issues/19752#change-103834 * Author: tomstuart (Tom Stuart) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) ---------------------------------------- The `--backtrace-limit` option was added in #8661 but it is not currently supported in the `RUBYOPT` environment variable, which appears to be a mistake. Unlike other long options which are not allowed in `RUBYOPT` (e.g. `--copyright`, `--version`, `--dump` and `--help`) it does not cause the interpreter to terminate, and cannot cause harm if read from the environment. During the initial discussion about the `--backtrace-limit` feature, Matz [suggested](https://bugs.ruby-lang.org/issues/8661#note-27) that he expected `RUBYOPT` to allow this option. Patch here, which also documents `--backtrace-limit` on Ruby’s `man` page: https://github.com/ruby/ruby/pull/8010 -- https://bugs.ruby-lang.org/

Issue #19752 has been updated by nobu (Nobuyoshi Nakada). https://github.com/ruby/ruby/pull/8068 Also you'll need the tests. ```ruby env = {"RUBYOPT" => "--backtrace-limit=5"} assert_in_out_err([env], "p Thread::Backtrace.limit", ['5'], []) assert_in_out_err([env, "--backtrace-limit=1"], "p Thread::Backtrace.limit", ['1'], []) ``` ---------------------------------------- Feature #19752: Allow `--backtrace-limit` to appear in RUBYOPT https://bugs.ruby-lang.org/issues/19752#change-103843 * Author: tomstuart (Tom Stuart) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) ---------------------------------------- The `--backtrace-limit` option was added in #8661 but it is not currently supported in the `RUBYOPT` environment variable, which appears to be a mistake. Unlike other long options which are not allowed in `RUBYOPT` (e.g. `--copyright`, `--version`, `--dump` and `--help`) it does not cause the interpreter to terminate, and cannot cause harm if read from the environment. During the initial discussion about the `--backtrace-limit` feature, Matz [suggested](https://bugs.ruby-lang.org/issues/8661#note-27) that he expected `RUBYOPT` to allow this option. Patch here, which also documents `--backtrace-limit` on Ruby’s `man` page: https://github.com/ruby/ruby/pull/8010 -- https://bugs.ruby-lang.org/

Issue #19752 has been updated by tomstuart (Tom Stuart). Thank you @nobu. I’ve rebased https://github.com/ruby/ruby/pull/8010 onto `master` to include your fix, and added your test. ---------------------------------------- Feature #19752: Allow `--backtrace-limit` to appear in RUBYOPT https://bugs.ruby-lang.org/issues/19752#change-103857 * Author: tomstuart (Tom Stuart) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) ---------------------------------------- The `--backtrace-limit` option was added in #8661 but it is not currently supported in the `RUBYOPT` environment variable, which appears to be a mistake. Unlike other long options which are not allowed in `RUBYOPT` (e.g. `--copyright`, `--version`, `--dump` and `--help`) it does not cause the interpreter to terminate, and cannot cause harm if read from the environment. During the initial discussion about the `--backtrace-limit` feature, Matz [suggested](https://bugs.ruby-lang.org/issues/8661#note-27) that he expected `RUBYOPT` to allow this option. Patch here, which also documents `--backtrace-limit` on Ruby’s `man` page: https://github.com/ruby/ruby/pull/8010 -- https://bugs.ruby-lang.org/
participants (4)
-
mame (Yusuke Endoh)
-
matz (Yukihiro Matsumoto)
-
nobu (Nobuyoshi Nakada)
-
tomstuart (Tom Stuart)