Ruby-on-rails 如何从命令行退出 IRB?(在mac上使用终端)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15705383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 21:42:34  来源:igfitidea点击:

How do I Quit IRB from the command line? (Using terminal on mac)

ruby-on-railsterminalirb

提问by Starkers

Basically, I'm typing along just fine in terminal, using IRB to run ruby commands:

基本上,我在终端中输入得很好,使用 IRB 运行 ruby​​ 命令:

2.0.0-p0 :014 > bank_account.withdraw(2222)
 => -1222 

But sometimes I accidentally miss out a quotation mark.

但有时我不小心漏掉了一个引号。

2.0.0-p0 :020 > BankAccount.create_for("Jim","Johnson)
2.0.0-p0 :021"> bank_account.withdraw(333)

If you look carefully, you'll see that the speech mark I missed out appears next to the line number on the left, next to the patch version.

如果仔细观察,您会看到我遗漏的语音标记出现在左侧行号旁边,补丁版本旁边。

From here on in, that speech mark appears everytime I run a command! And it stops the commands working:

从这里开始,每次我运行命令时都会出现那个语音标记!它停止命令工作:

2.0.0-p0 :021"> BankAccount.create_for("Julian","Hurley")
2.0.0-p0 :022"> BankAccount.create_for("Katt","Smith")
2.0.0-p0 :023"> exec(##代码##)

What I want to know is, how do I get rid of that quotation mark? Or quit IRB from the command line in order to reset it?

我想知道的是,如何去掉那个引号?或者从命令行退出 IRB 以重置它?

回答by muttonlamb

If you haven't closed a quote, just put a quote in and hit return.

如果您还没有关闭报价单,只需输入报价单并按回车键即可。

Exiting from the console can be done by typing exit, though in the circumstance your are would need to hit Control - C

可以通过键入 exit 从控制台退出,但在这种情况下,您需要按 Control - C

回答by UrbanDev

I was having the same problem. To exit irbwithin the terminal, type exit.

我遇到了同样的问题。要irb在终端内退出,请键入exit

回答by S E

Control - C followed by Control - Z. I hope it helps!

Control - C 然后是 Control - Z。我希望它有帮助!

回答by qknowswhat

Use Ctrl-D, it is an end-of-input for irb. If you are in the middle of some command, use Ctrl-C first to terminate the input of this command.

使用Ctrl-D,它是 irb 的输入结束。如果您正在执行某个命令,请先使用 Ctrl-C 来终止该命令的输入。

回答by V? Thanh

Type quit()and hit Enterto exit ruby.

键入quit()并点击Enter退出 ruby​​。