Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cygwin Bash.exe vs. mintty.exe [closed]

Tags:

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?

like image 583
George Newton Avatar asked Apr 12 '14 13:04

George Newton


People also ask

What is Mintty EXE?

mintty is a free and open source terminal emulator for Cygwin, the Unix-like environment for Windows. It features a native Windows user interface and does not require a display server; its terminal emulation is aimed to be compatible with xterm.

Is Cygwin a bash terminal?

The Cygwin installation creates a Bash shell along with a UNIX environment by which you can compile and run UNIX-like programs. Using this one can even create an emulated X server on your windows box and run UNIX-like GUI software tools.

What is Cygwin bash?

description: Bash is an sh-compatible shell that incorporates useful features from the Korn shell (ksh) and C shell (csh). It is intended to conform to the IEEE POSIX P1003. 2/ISO 9945.2 Shell and Tools standard. It offers functional improvements over sh for both programming and interactive use.

How do I exit Mintty?

Closing a sessionClicking the window's close button, pressing Alt+F4, or choosing Close from the window menu sends a SIGHUP signal to the process running in mintty, which normally causes it to exit.


1 Answers

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. 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.

(The initial release of Windows 10 included a much-improved console, and the more recent Windows Terminal add-on improves things further, but MinTTY remains the more powerful option, 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.

like image 60
Warren Young Avatar answered Sep 29 '22 13:09

Warren Young