Skip to content

Raise UndefinedPromptMode when --prompt has no value - #1260

Open
taekop wants to merge 1 commit into
ruby:masterfrom
taekop:fix-prompt-option-without-value
Open

taekop wants to merge 1 commit into
ruby:masterfrom
taekop:fix-prompt-option-without-value

Conversation

@taekop

@taekop taekop commented Oct 6, 2026

Copy link
Copy Markdown

Fixes #910

irb --prompt (also --prompt-mode and --prompt=) with no mode crashed in parse_opts with undefined method 'upcase' for nil (NoMethodError). It now raises IRB::UndefinedPromptMode, the same error IRB already uses for an unknown mode such as irb --prompt bogus.

Listing the available modes is left out: modes can still be added by .irbrc after option parsing, so the list isn't final at that point.

Testing

  • Added test_prompt_option to test/irb/test_init.rb. It covers --prompt simple, --prompt-mode=inf-ruby and the missing-value case. On master it fails with the NoMethodError, and with this change it passes.
  • bundle exec rake test: 411 tests, 0 failures, 0 errors (3 omissions).
  • bundle exec rubocop lib/irb/init.rb test/irb/test_init.rb: no offenses.
  • Manual check: irb --prompt now prints Undefined prompt mode(). (IRB::UndefinedPromptMode). --prompt simple, --prompt=classic, --prompt-mode inf-ruby and --noprompt work as before.

`irb --prompt` without a mode crashed with NoMethodError on nil.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display better error message if no prompt mode is given

1 participant