简体   繁体   English

在W32 Emacs上,为什么Cygwin或MinGW bash中的Ctrl-D会重复出现EOF?

[英]On W32 Emacs why does Ctrl-D in Cygwin or MinGW bash issues repeated EOFs?

I'm using W32 GNU Emacs 24.1.50.1 with Cygwin bash 3.2.51. 我正在使用带有Cygwin bash 3.2.51的W32 GNU Emacs 24.1.50.1。 I know that this combination is very troublesome (see EmacsWiki and Cygwin list ). 我知道这种组合非常麻烦(请参阅EmacsWikiCygwin列表 )。 However the problem I want to solve now is not confined to Cygwin. 但是,我现在要解决的问题并不限于Cygwin。 I got the issue with MinGW as well. 我也遇到了MinGW的问题。 So, the problem is: 因此,问题是:

In Emacs start a shell via Mx shell provided you have set up the variables shell-file-name and explicit-bash-args appropriately (see eg here ). 在Emacs中,通过Mx shell启动Mx shell前提是您已经适当设置了变量shell-file-nameexplicit-bash-args (请参见例如此处 )。 Then issue a command which expects stdin input, eg cat . 然后发出一个需要标准输入的命令,例如cat To cancel out of cat you can usually type Ctrl-D once and you return to the shell prompt. 为了抵消的cat通常可以按Ctrl-d 一次 ,并返回到shell提示符。 In W32 emacs when you do this (or even when you issue explicitly Mx comint-send-eof ) the cat command gets exited and the bash shell quits as well. 在W32 emacs中,执行此操作(或什至当您明确发出Mx comint-send-eof ),cat命令将退出 bash shell也将退出。

I tried to increases bash's "resilience' by setting the environment variable IGNOREEOF to, say, 5, but then a single Ctrl-D results in the following output 我试图通过将环境变量IGNOREEOF设置为5来提高bash的“弹性”,但随后使用Ctrl-D会产生以下输出

$ Use "exit" to leave the shell.
$ Use "exit" to leave the shell.
$ Use "exit" to leave the shell.
$ Use "exit" to leave the shell.
$ Use "exit" to leave the shell.
$ exit

Process shell finished

and, of course, the bash has exited again. 当然,重击又退出了。 This problem only happens when the shell runs in W32 emacs - Cygwin bash through the Cygwin tty window and MinGW bash through its own MinTTY work fine. 仅当外壳程序在W32 emacs中运行时才会发生此问题-通过Cygwin tty窗口运行Cygwin bash,并且通过其自己的MinTTY运行MinGW bash正常。

Why is this happening in W32 Emacs and how can I just exit the running subcommand (eg cat ) when using W32 Emacs without exiting the bash shell? 为什么在W32 Emacs中会发生这种情况?在使用W32 Emacs时如何退出退出运行的子命令(例如cat )而不退出bash shell?

The notion of tty like you expect it to behave doesn't really exist in the W32 worl. 就像您期望的那样,tty的概念在W32世界中并不真正存在。 If you want to see this Unixy behavior, you need not only to run a Cygwin program but that Cygwin program needs to talk to another Cygwin program (Emacs, terminal, you name it). 如果您想查看这种Unixy行为,则不仅需要运行Cygwin程序,而且该Cygwin程序需要与另一个Cygwin程序(Emacs,终端,您命名)对话。 IOW you'll only get that with the Cygwin version of Emacs. IOW,您只能使用Cygwin版本的Emacs来实现。

The GNU Emacs FAQ for MS Windows notes that this issue exists for any sub-process in the shell buffer. 适用于MS WindowsGNU Emacs常见问题解答指出,外壳缓冲区中的任何子进程都存在此问题。 So it affects the DOS command line as well (but of course you don't usually use Ctrl-D in DOS, so it's not so noticeable). 因此,它也会影响DOS命令行(但是,当然,您通常在DOS中通常不使用Ctrl-D,因此不太明显)。 No workaround is suggested in the FAQ, so I'm guessing that there's no easy fix. FAQ中没有建议解决方法,因此我猜测没有简单的解决方法。

Usually you can use Ctrl-Z as well as Ctrl-D. 通常,您可以使用Ctrl-Z以及Ctrl-D。 Take a look at this note: 看一下这个注释:

http://ignaciopp.wordpress.com/2009/07/02/emacs-shell-workaround-for-killing-input-in-windows-version/ http://ignaciopp.wordpress.com/2009/07/02/emacs-shell-workaround-for-killing-input-in-windows-version/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM