cygwin 下的 Windows 应用程序有时无法识别输入键
在工作中,我经常使用 Cygwin,因为它为我在 Windows 的广阔沙漠中提供了一片小绿洲。 我不可避免地最终会通过 bash shell 运行一些非 Cygwin 程序,例如构建脚本(内部创建的批处理文件)和 Subversion CLI 二进制文件(我安装了 Windows 程序)。 99% 的情况下,使用此设置不会出现任何问题。 然而,另外 1% 会导致一个奇怪的问题:
对于构建脚本和 SVN,大多数时候回车键都会被正确解释。 例如,我将启动数据库创建脚本,它会提示我输入服务器名称。 我输入“localhost”并按 Enter 键。 一切安好。 然后,如果有错误,它就会到达末尾,并使用 more
打印出内容。 more
无法识别我按下的任何键。 我必须按 Ctrl-C 退出它。
同样,如果我进行 Subversion 更新,通常一切都会很好。 然而,在发生交互式冲突解决的情况下,我通常会输入“tf”代表“theirs-full”,然后按 Enter 键,但什么也没有发生。 我必须按 Ctrl-C 退出它并通过强制合并重新运行更新或在 Windows 中使用 TortoiseSVN 来执行此操作。
知道为什么 Cygwin 似乎随机不将回车键传递给程序吗? 我认为这可能与 Unix 与 Windows 风格的行结尾有关,所以我尝试手动输入这些字符,但这似乎没有什么区别。 谢谢。
编辑:我刚刚再次遇到这种情况,我意识到了一些事情。 这是 SVN 提示我输入密码。 我输入了密码,它在屏幕上回显(坏),然后按回车键……什么也没有。 再按几次 Enter 键,光标移动,但什么也没有发生。 我按 Ctrl-C,它会将我转回 bash,然后显示“bash:[我的密码]:未找到命令”,后面跟着的新提示的数量等于我按 Enter 键的次数。 所以发生的情况是输入从未到达 SVN,但在 SVN 退出后以某种方式被 bash 读取。 我认为这可以帮助某人弄清楚发生了什么事。
At work, I use Cygwin a lot because it offers me a small oasis in the vast desert of Windows. I inevitably end up running some non-Cygwin programs through the bash shell, such as build scripts (batch files created in-house) and the Subversion CLI binaries (I have the Windows ones installed). 99% of the time, I don't have any problems using this setup. The other 1%, however, causes a strange issue:
With both the build scripts and SVN, most of the time the enter key is interpreted correctly. For instance, I'll kick off the database creation script and it will prompt me for the server name. I type in "localhost" and hit enter. Everything's fine. Then it gets to the end, if there are errors, and prints things out using more
. No key that I press is recognized by more
. I have to Ctrl-C out of it.
Similarly, if I do a Subversion update, normally everything is fine. In the case where the interactive conflict resolution happens, however, I'll usually type in "tf" for "theirs-full" and hit enter, but nothing happens. I have to Ctrl-C out of it and re-run the update with force merge or use TortoiseSVN in Windows to do it.
Any idea why Cygwin seems to randomly not be passing the enter key through to the programs? I considered that it may have something to do with Unix vs Windows style line endings, so I've tried typing those characters manually, but that doesn't seem to make a difference. Thanks.
Edit: I just had this happen to me again and I realized something. It was SVN prompting me for a password. I typed in the password, which it echoed to the screen (bad) and hit enter... nothing. Hit enter a few more times, the cursor moves, but nothing happens. I hit Ctrl-C and it dumps me back to bash, which then says "bash: [my password]: command not found" followed by a number of new prompts equal to the number of times I hit the enter key. So what happened is the input never made it to SVN, but somehow got read by bash after SVN exited. I thought that may help someone figure out what is going on.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,我认为您遇到了 Cygwin 和 windows/dos 控制台应用程序的问题之一。 请参阅 http://www.cygwin.com/cygwin 处的“控制台程序” -ug-net/using-efficiently.html。
这只是 Windows 控制台应用程序的限制。 例如,此行为对于 Windows myqsl cmd 客户端和 svn 客户端很常见。
这里有一些需要注意的事情——我已经成功地在 Windows mysql 和 Windows svn 客户端上使用了这种方法:
1) 尝试确保你的 CYGWIN 环境变量中没有“tty”,看看这是否有帮助(在“我的电脑”->“属性”->“高级”->“环境变量”中取消设置并关闭/重新启动任何 cygwin bash 提示)。
2) 不要使用 RXVT——而是使用基本的 Cygwin cmd 提示符。 这是因为 RXVT 意味着“tty”并且会破坏上面的#1。
3) 尝试为您遇到问题的命令查找“本机”Cygwin 包,而不是使用 Windows 命令。 (不过,我还没有找到 cygwin 的 1.6 svn 客户端。)
祝你好运!
达斯汀
Unfortunately, I think you are hitting one of the issues of Cygwin and windows/dos console apps. See "Console Programs" at http://www.cygwin.com/cygwin-ug-net/using-effectively.html.
It is just a limitation on windows console apps. This behavior is common for the windows myqsl cmd client and svn client, for example.
Here are some things to note -- I've successfully used this approach with both the Windows mysql as well as Windows svn clients:
1) Try making sure you do NOT have "tty" in your CYGWIN environment variable and see if that helps (unset it in My Computer->properties->advanced->Environment Variables and close/restart any cygwin bash prompts).
2) Do not use RXVT -- instead, use the basic Cygwin cmd prompt. This is because RXVT implies "tty" and will break #1 above.
3) Try finding a "native" Cygwin package for the cmds you are having issues with instead of using the Windows cmds. (I haven't found a 1.6 svn client for cygwin yet, though.)
Good luck!
Dustin
关于 mintty 项目的冗长讨论在这里 - http://code.google .com/p/mintty/issues/detail?id=56
提到的一种在我的案例中有效的解决方案(输入本机颠覆的身份验证密码)是 conin - http://code.google .com/p/mintty/downloads/detail?name=conin-0.0.2.zip&can=1&q=label%3ADevelopment
The lengthy discussion on the mintty project is here - http://code.google.com/p/mintty/issues/detail?id=56
One solution mentioned which worked in my case (entering authentication passwords for native subversion) is conin - http://code.google.com/p/mintty/downloads/detail?name=conin-0.0.2.zip&can=1&q=label%3ADevelopment