Cygwin Bash.exe与mintty.exe [英] Cygwin Bash.exe vs. mintty.exe
问题描述
我试图在 bash.exe
和 mintty.exe
上运行Unix命令,这些命令位于 Cygwin64 / bin
(例如usr / bin / bash.exe)。当我尝试运行Unix命令 ls
时,我得到 bash:ls:命令未找到
。但是,当我单击Cygwin终端的桌面图标,并在生成的Cygwin终端中输入 ls
时,Unix命令如 ls $工作!为什么Unix命令在
bash.exe
和 mintty.exe
上不起作用,但是在终端上单击图标?此外, bash.exe
和 mintty.exe
带来的两个shell有什么区别?
这两个程序在任何方面都不能相互替代。 Bash是 shell ,而MinTTY是终端仿真器。 MinTTY通常会在其内部运行用户的外壳程序,外壳程序可能是Bash,也可能不是。也就是说,通常您会同时使用这两个程序。
如果检查MinTTY快捷方式,即Cygwin的 setup.exe
构建,您会发现它不是该程序的简单启动。它以 mintty-
的身份运行,它告诉MinTTY将用户的shell作为登录 shell运行。
这是您遇到的问题。如果运行不带选项的 bash.exe
,您将得到带有默认配置的裸壳,这意味着它不执行添加Cygwin <$ c $的操作c> / bin 到您的 PATH
。同样,如果运行不带选项的 mintty.exe
,它将运行不带选项的用户外壳程序。当您给 mintty.exe
加上破折号而不是程序名称时,它将运行用户的外壳程序作为登录外壳程序: bash -l </ code>,而不仅仅是
bash
。该选项使Bash在启动后立即读取大量启动脚本,这将设置命令PATH以及更多其他内容。
因此,如果必须运行由于某些原因,在MinTTY之外的 bash.exe
,您可以说 bash -l </ code>使行为更接近<通过
。但是,您将失去所有终端仿真器功能。 MinTTY具有比Windows控制台更好的复制粘贴行为,例如,特别是在Windows 8和更低版本的Windows上。 mintty-
运行时,code> bash.exe
(包括Windows 10 经过改进的控制台,但是MinTTY仍然更好,恕我直言,特别是在与Cygwin合作时。)
在Cygwin命令提示符下说 man mintty
MinTTY为您所做的所有事情。在 MinTTY手册页的邀请部分中回答了这个特定问题。 p>
I am trying to run Unix commands on both the bash.exe
and mintty.exe
, found in Cygwin64/bin
(e.g., usr/bin/bash.exe). When I try to run the Unix commmand ls
, I get bash: ls: command not found
. However, when I click on the desktop icon for the Cygwin terminal, and enter ls
into the resulting Cygwin terminal, the Unix commmands like ls
work! Why do Unix commands not work on bash.exe
and mintty.exe
, but on the terminal the results from clicking the icon? Furthermore, what is the difference the two shells brought by bash.exe
and mintty.exe
?
These two programs are not in any way alternatives to one another. Bash is a shell, and MinTTY is a terminal emulator. MinTTY normally runs your user's shell within itself, which may or may not be Bash. That is to say, you normally use the two programs together.
If you examine the MinTTY shortcut that Cygwin's setup.exe
builds, you will find that it isn't a simple launch of the program. It runs it as mintty -
, which tells MinTTY to run your user's shell as a "login" shell.
This is the problem you have run into. If you run bash.exe
without options, you just get the naked shell, with its default configuration, which means it doesn't do things like add the Cygwin /bin
to your PATH
. Likewise, if you run mintty.exe
without options, it runs your user's shell without options. When you give a dash to mintty.exe
instead of a program name, it runs your user's shell as a login shell: bash -l
, rather than just bash
. That option causes Bash to read in a bunch of startup scripts immediately after launch, which sets up the command PATH and a lot more besides.
Thus, if you had to run bash.exe
outside MinTTY for some reason, you could say bash -l
to get behavior somewhat closer to that of bash.exe
when run via mintty -
. You would lose out on all of the terminal emulator features, however. MinTTY has much better copy-paste behavior than Windows' console does, for example, particularly on Windows 8 and older.
(Windows 10 included a much-improved console, but MinTTY is still better, IMHO, particularly when working with Cygwin.)
Say man mintty
at a Cygwin command prompt for a fuller explanation of all the things MinTTY does for you. This particular question was answered in the INVOCATION section of the MinTTY manual page.
这篇关于Cygwin Bash.exe与mintty.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!