Is there a way to make the Scala REPL not stop with CTRL-C
我正在使用Scala REPL交互地测试正在构建的一些哈希函数。我一直在产品代码(Eclipse),浏览器和Scala解释器之间进行切换,以复制/粘贴值和结果。在混合中,我经常在解释器上执行CTRL-C,退出会话并失去我的所有功能。
是否有任何方法可以让Scala REPL忽略CTRL-C,或者甚至更好地对其执行"粘贴"?我正在使用Linux。
我只知道如何防止REPL退出。重新映射
1 2 3 4 5 6 7 8 9 10 | #!/bin/bash #switch off sensitivity to ^C trap '' 2 # here goes REPL invoke scala #get back sensitivity to ^C trap 2 |
陷阱命令
defines and activates handlers to be run when the shell receives
signals
or other conditions.
2是SIGINT值(当您按下
作为本机Scala REPL的替代方法,您可以使用Ammonite,它可以处理Ctrl C:
The traditional Scala REPL doesn't handle runaway code, and gives you no option but to kill the process, losing all your work.
Ammonite-REPL lets you interrupt the thread, stop the runaway-command and keep going.
该repl已经拦截了ctrl-C,但显然在Linux上不起作用。它确实适用于osx。如果使用Linux的人打开了一张有足够详细信息的票证以指示为什么不这样做,那么我可以修复它。