Skip to content

Rye::Cmd.add_command breaks for programs with "-" in them (method must match program name) #60

Description

@jphackworth

I wanted to add ssh-keygen to the list of whitelisted commands.

Rye::Cmd.add_command :ssh_keygen, "/usr/bin/ssh-keygen"

But received the following error:

irb(main):004:0> Rye::Cmd.add_command :ssh_keygen, "/usr/bin/ssh-keygen"                                               
=> #<Proc:0x00000000a70d00@/var/lib/gems/2.0.0/gems/rye-0.9.12/lib/rye/cmd.rb:354 (lambda)>
irb(main):005:0> Rye.shell :ssh_keygen, "--help"                                                                       
Rye::CommandNotFound: ssh_keygen
        from /var/lib/gems/2.0.0/gems/rye-0.9.12/lib/rye.rb:193:in `prepare_command'
        from /var/lib/gems/2.0.0/gems/rye-0.9.12/lib/rye.rb:236:in `shell'
        from (irb):5
        from /usr/bin/irb2.0:12:in `<main>'

I finally realised that the method has to match the program name, which isn't helpful when the program name contains a dash ("-"), like ssh-keygen does.

What I've had to do is:

$ sudo ln -s /usr/bin/ssh-keygen /usr/bin/sshkeygen
...
$ irb2.0
irb(main):001:0> require 'rye'
=> true
irb(main):002:0> Rye::Cmd.add_command :sshkeygen, "/usr/bin/sshkeygen"
=> #<Proc:0x00000000f47d38@/var/lib/gems/2.0.0/gems/rye-0.9.12/lib/rye/cmd.rb:354 (lambda)>
irb(main):003:0> Rye.shell :sshkeygen, "--blah"
=> [, unknown option -- -; usage: sshkeygen [options]; Option

(Which now works)

Activity

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

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