Skip to content

ORI should work outside of a readline environment #3

@janlelis

Description

@janlelis

Hey @dadooda,
first of all, thanks for this gem, it still work fabulous after all that time!

One little thing is that I've noticed the gem fails if it is not in a readline context. Reproducible like this:

ruby -r ori -e "p [].ri :reverse"
# …/ori-0.1.0/lib/ori/internals.rb:187:in `do_history': uninitialized constant ORI::Internals::Readline (NameError)

It also fails when readline is required:

ruby -r readline -r ori -e "p [].ri :reverse"
# …/ori-0.1.0/lib/ori/internals.rb:282:in `get_ri_arg_prefix': undefined method `match' for nil:NilClass (NoMethodError)

Here is an idea for a patch (for the latter problem):

  module ORI::Internals
    def self.get_ri_arg_prefix(cmd)
      if cmd && (mat = cmd.match /\A(\s*.+?\.ri)\s+\S/)
        mat[1]
      end
    end
end
  • Ruby version 2.6.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions