Bash – How similar is Apple’s terminal.app to a bash terminal on Linux

bashosx

I know that Apple's Terminal.app provides a bash shell. Are there any differences between this and a bash on Linux?

Best Answer

Terminal is a terminal emulator. It interprets various control sequences sent by programs (control characters like CR, LF, BS and longer control sequences for commands like “clear screen”, “move cursor up 3 lines”, etc.). Terminal is the same kind of program as xterm, rxvt, Konsole, or GNOME Terminal. Almost all modern terminal emulators support the “xterm” control sequences, so they are generally highly compatible (and most programs use the ncurses library and its terminfo database to abstract over the actual control sequences).

bash is a shell. It interprets commands that usually involve running other programs. In normal, interactive use the shell’s input comes from a user via a terminal emulator. The terminal emulator and the shell are connected via a “pseudo tty” device (e.g. /dev/pts/24, or /dev/ttyp9).

Because the tty devices are the only interface between Terminal and bash, they are completely independent. You can use bash with iTerm instead of Terminal, and you can use zsh instead of bash inside a Terminal window.

The version of bash installed on your Mac OS X and Linux systems may be different, but should be fairly easy to install pretty much whatever version of bash you want on either system. You might look at MacPorts, homebrew, or Fink for ways to install recent versions of bash (and other shells) on Mac OS X. Whatever Linux distribution you are using surely comes with packages for common shells.

Related Question