Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown commands crash interpreter #106

Closed
camdez opened this issue Oct 17, 2014 · 0 comments
Closed

Unknown commands crash interpreter #106

camdez opened this issue Oct 17, 2014 · 0 comments

Comments

@camdez
Copy link
Contributor

camdez commented Oct 17, 2014

To reproduce:

Add a keybinding to your ~/.inputrc file which references a non-existent command.

Might I suggest the following since you need to put a literal escape character in the file for bindings to work (#105):

$ ruby -e 'puts "\"\en\": next-history"' >> ~/.inputrc

Then run rb-readline and press Meta-N:

$ ruby -Ilib -S irb                                   
irb(main):001:0> /Users/camdez/src/rb-readline/lib/rbreadline.rb:4322:in `_rl_dispatch_subseq': undefined method `rl_next_history' for RbReadline:Module (NoMethodError)
        from /Users/camdez/src/rb-readline/lib/rbreadline.rb:4331:in `_rl_dispatch_subseq'
        from /Users/camdez/src/rb-readline/lib/rbreadline.rb:4311:in `_rl_dispatch'
        from /Users/camdez/src/rb-readline/lib/rbreadline.rb:4727:in `readline_internal_charloop'
        from /Users/camdez/src/rb-readline/lib/rbreadline.rb:4801:in `readline_internal'
        from /Users/camdez/src/rb-readline/lib/rbreadline.rb:4823:in `readline'
        from /Users/camdez/src/rb-readline/lib/readline.rb:45:in `readline'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb/input-method.rb:152:in `gets'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb.rb:472:in `block (2 levels) in eval_input'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb.rb:624:in `signal_status'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb.rb:471:in `block in eval_input'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:190:in `call'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:190:in `buf_input'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:105:in `getc'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb/slex.rb:206:in `match_io'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb/slex.rb:76:in `match'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:290:in `token'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:266:in `lex'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:237:in `block (2 levels) in each_top_level_statement'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:233:in `loop'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:233:in `block in each_top_level_statement'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:232:in `catch'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:232:in `each_top_level_statement'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb.rb:488:in `eval_input'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb.rb:397:in `block in start'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb.rb:396:in `catch'
        from /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/irb.rb:396:in `start'
        from /usr/local/var/rbenv/versions/2.0.0-p247/bin/irb:12:in `<main>'

This is a big problem as some commands are named differently between GNU Readline and rb-readline (e.g. GNU Readline's next-history shown here, and rb-readline's get-next-history), and therefore a valid .inputrc file with real GNU Readline commands might crash the interpreter while a user is attempting to use an rb-readline powered tool.

I'd recommend that unknown commands be ignored as they are in GNU Readline.

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

No branches or pull requests

1 participant