Question

A simple example:

1.9.3p448 :003 > `ls #{File.expand_path('../../', File.dirname(__FILE__))
1.9.3p448 :004 > `
1.9.3p448 :005`>
1.9.3p448 :006`> }
1.9.3p448 :007`> `
1.9.3p448 :008 > `
1.9.3p448 :009`> `
1.9.3p448 :010 > )

Ctrl-c doesn't work here. If I know what the expected closing character is, then I can type that to close the sequence. That requires mental work and sometimes I'll get it wrong, as I did here.

Is there a way to simply tell irb that I want it to drop the input string that it's seen so far?

Also applies to "rails console" and debugger.

EDIT The answer that works for me is ctrl-c after commenting my entire irbrc file. Ctrl-D still doesn't work for me, but YMMV

Was it helpful?

Solution

Press ctrl+D and then return; you'll get a syntax error for whatever statement you've failed to terminate, and you'll be able to start a fresh statement:

irb(main):001:0> ziuhas'
irb(main):002:0' ^D
irb(main):002:0>
SyntaxError: (irb):1: unterminated string meets end of file
    from /Users/matthew.eagar/.rbenv/versions/1.9.3-p327/bin/irb:12:in `<main>'

OTHER TIPS

Usually ^D does this.

The alternative is the more abrupt ^C.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top