Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange irb behaviour, listing content current directory

Tags:

ruby

irb

When I paste this code in irb prompt I get listing of current directory after line if true.

def some_method()

  if true
        raise StandardError
    end

end

Example of output:

irb(main):151:0> def some_method()
irb(main):152:1> 
irb(main):153:1*   if true
irb(main):154:2> 
.Skype/                          .m2/                             Desktop/
...

I use irb 0.9.5(05/04/13) and ruby 1.8.7 (2011-12-28 patchlevel 357).

Is this a bug, or something else?

like image 383
XoR Avatar asked Mar 04 '12 22:03

XoR


1 Answers

The following line will have tab characters in it:

        raise StandardError

irb uses readline which means that the tab key is used for tab completion. Double tab will show you all the available options.

To see this in action, just launch irb and hit the tab key twice.

See https://superuser.com/questions/37148/how-to-disable-double-tab-to-show-available-commands-in-linux-console for guidance on how to disable it.

like image 100
Don Cruickshank Avatar answered Oct 11 '22 16:10

Don Cruickshank