Terminal vs bash?
The machine in this picture is a (video) terminal, more specifically a VT100 by Digital Equipment Corporation.
Decades ago when computers were big, instead of having personal computers for each user, they could have had a terminal, a dummy device with display and keyboard, that is connected to a main computer via a cable. A VT100 is not a computer, but just a keyboard and a display. There usually were several of these connected to a single computer.
Thus decades ago a Unix computer was accessed via a terminal, which was a physical device. As the personal computer came along, and graphical user interfaces became commonplace, there was (and still is) a way to access the Unix command line as if by such a terminal device - applications called terminal emulator. The Terminal program in OS X is a terminal emulator; most of the terminal emulators of the present day still emulate that very same VT100 device quite closely, i.e. most of the programs run in a window of the Terminal
application look exactly the same as they would look if run on the big computer of 70s and the data displayed on such a terminal device. To the programs, each window in your terminal emulator behaves like one of these devices; most command line programs couldn't notice a difference (though you could find it difficult to connect a genuine VT100 to your MBP).
A video terminal was the successor of a device called a hard-copy terminal, a device that would have a keyboard and printer - all the output from programs would be printed on the paper instead. One can imagine that a video terminal was a big improvement over such devices. An example of a hard-copy terminal, a TeleType Model 33 ASR:
This device was also called teletypewriter, teletyper, or tty for short; and the tty stuck from the early 70s, and the interface for a such a device, or terminal emulator is still called a tty, and in many programming languages outputting text for display in a terminal window still is called "printing"; originally it was not a metaphor but a fact.
The shell has always been there - from the dawn of Unix, it was the program that was run after you entered your login name and password on the terminal, to access the central computer. The first shell program was the Thompson shell (sh
) from 1971, which in 1977 was superseded by Bourne shell, also called sh
. Early on, it was designed so that that this was just another program that could be updated easily, and that users could run their own program instead of the default shell.
The GNU project then produced from scratch an improved shell called bash
, short for Bourne-again shell, which Apple decided to ship with MacOS X too.
Back in 1970s, the distinction was clear: a terminal was that what seemed like 30 kg piece of solid cast iron frame wrapped in cream-colour plastic case with a glass display and keyboard in front of you, or even a device with just a keyboard and printer, whereas a shell was a program running on the main computer interpreting your commands.
When you launch a terminal it will always run some program inside it. That program will generally by default be your shell. On OS X, the default shell is Bash. In combination that means that when you launch Terminal you get a terminal emulator window with bash
running inside it (by default).
You can change the default shell to something else if you like, although OS X only ships with bash
and tcsh
. You can choose to launch a custom command in a new terminal with the open
command:
open -b com.apple.terminal somecommand
In that case, your shell isn't running in it, and when your custom command terminates that's the end of things.
If you run bash
inside your terminal that is already running bash
, you get exactly that: one shell running another. You can exit the inner shell with Ctrl-D or exit
and you'll drop back to the shell you started in. That can sometimes be useful if you want to test out configuration changes or customise your environment temporarily — when you exit the inner shell, the changes you made go away with it. You can nest them arbitrarily deeply. If you're not doing that, there's no real point in launching another one, but a command like bash some-script.sh
will run just that script and then exit, which is often useful.
The differences between interactive and non-interactive shells are a bit subtle and mostly deal with which configuration files are loaded, which error behaviours there are, and whether aliases and similar are enabled. The rough principle is that an interactive shell gives you the settings you'd want for sitting in front of it, while a non-interactive shell gives you what you'd want for a standalone script. All of the differences are documented explicitly in the Bash Reference Manual, and also in a dedicated question on this site.
For the most part, you don't need to care. There's not often a reason to launch another shell, and when you do you'll have a specific purpose in mind and know what to do with it.
You are missing your terminal is already running bash
(or another shell interpreter) in the first place.
A terminal and more precisely a terminal emulator in your case is just a device passing keystrokes to an underlying program and displaying whatever characters are sent to it. While it runs a shell by default, nothings forbids to start a terminal running a different text application, like a text editor or whatever.
If you are already in an interactive session, running bash
and bash -i
wouldn't indeed make a difference.