Readline insists in ordering the returned array

Hi, I want to use Ruby Readline for a custom console. Commands are
“ddd”, “bbb”, “aaa”, “ccc” and I want they to be shown in that order
when pressing TAB with empty buffered line. Example code:


require “readline”

commands = %w{ddd bbb aaa ccc}

Readline.completion_proc = proc do |s|

while line = Readline.readline(">>> ", true)

Running it:

aaa bbb ccc ddd

I strongly need that the commands are shown in the original order! but
Readline shorts them:

ddd bbb aaa ccc

Being a C ruby code I expect it’s hard to monkey patch it. Maybe I
miss something to keep the order of the array?

Thanks a lot.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs