18

在 Mongo 的 JavaScript shell 中执行查询感觉很像在 bash shell 中执行命令。正因为如此,我的手指不断尝试Ctrl+C退出我想要“中止”并返回命令提示符的命令。不幸的是,在 2.0.4 的 mongo shell 中,当 I Ctrl+时C,它会将我从 JavaScript shell 中删除,而不仅仅是中止命令并给我命令提示符。

JavaScript shell 中有没有一种方法可以放弃当前命令而不执行它并返回命令提示符?

4

1 回答 1

21

What I've always naturally done is type a ( and then immediately hit enter three times. The shell will assume you are just hitting enter to break up your command, but if you hit enter 2 more times it will exit back to the shell. It's wonky, but it works.


Edit: Use ctrl+d, which "kills the shell" according to http://www.gotothings.com/unix/bash-hotkeys.htm. If you hit this once after hitting enter in the middle of typing a command in the mongo shell, it will exit your continuation and get you back to a clean mongo prompt. Hitting it twice will exit the mongo shell.

于 2012-06-08T17:02:36.167 回答