← New search

Other meanings of Bash (Unix shell)

Unix computing

Bash (Unix shell)

Bash is a Unix shell and command language used for interactive command-line work, scripting, and process control. Created as a free replacement for the Bourne shell, it combines traditional Unix syntax with features such as command history, programmable completion, arrays, arithmetic, and shell functions.1

1989
Initial public release
GNU Bash
4.4
POSIX shell standard lineage
Command language
GPLv3
Current licensing family
Free software
1

Definition and origins

Bash is a command interpreter that reads commands from a terminal or script, expands them, and launches programs or performs shell operations. Its name is an acronym for “Bourne Again SHell,” a pun on the Bourne shell, whose syntax strongly influenced Unix scripting. Brian Fox wrote the first Bash implementation for the GNU Project, and Chet Ramey later became its principal maintainer.

Bash became the default interactive shell on many GNU/Linux installations and was also widely used on earlier versions of macOS. It is separate from the Linux kernel: Bash is an application that communicates with the operating system through standard process, file, and terminal interfaces. The shell can run external programs, but built-in commands such as cd, export, and read execute inside the shell process because they must alter its state.

2

Command language and execution model

Bash’s central language combines command sequencing with expansion and redirection. A command line may contain pipelines, conditional lists, subshells, background jobs, functions, variables, and compound commands. Before execution, Bash performs stages including tokenization, parameter expansion, command substitution, arithmetic expansion, field splitting, and pathname expansion; quoting controls which stages apply.

Pipelines connect the standard output of one process to the standard input of another, while redirections attach commands to files or other descriptors. Bash also supports job control for foreground and background processes, signals, traps, and exit statuses. Its syntax is closely related to the POSIX shell language, but many Bash-only features—such as indexed and associative arrays, process substitution, and extended pattern matching—can reduce portability when scripts are run by sh or another shell.1

3

Interactive use and scripting

Bash serves two overlapping purposes: an interactive environment for users and an interpreter for shell scripts. Interactive Bash maintains command history, offers programmable completion, reads startup files, and can display a customizable prompt. Readline, the separate GNU library commonly used by Bash, supplies editing and history-navigation facilities.2

Scripts use variables, functions, loops, tests, and commands to automate system administration, software builds, data-processing pipelines, and application launchers. A shebang such as #!/usr/bin/env bash asks the operating system to invoke Bash, although the exact interpreter path and environment remain deployment choices. Robust scripts generally quote expansions, check important command results, distinguish data from code, and avoid parsing arbitrary text with fragile assumptions. Bash’s set -e, set -u, and pipefail options can help expose errors, but they have nuanced behavior and are not substitutes for deliberate error handling.

4

Lesser-known aspects

Bash has several features that are powerful but easy to overlook. Its coproc construct creates a coprocess with connected input and output, process substitution exposes command output through a file-like path, and programmable completion can use shell functions to complete options or domain-specific values. The shopt command controls non-POSIX behaviors, including recursive globbing with globstar and extended pattern matching.

Bash also has compatibility modes that alter historical or POSIX-related behavior, allowing scripts to approximate older releases or standard shell semantics. Security problems often arise not from Bash itself but from unsafe composition: unquoted filenames, command substitution of untrusted input, exported functions, or shell invocation through web and service interfaces. The Shellshock vulnerabilities disclosed in 2014 demonstrated how environment-based function definitions could create serious exposure in affected Bash versions, prompting widespread patching and renewed attention to shell boundaries.3

Glossary

shell
A program that interprets commands and provides an interface to operating-system services.
pipeline
A sequence of commands in which one command’s output becomes another command’s input.
command substitution
An expansion that replaces a command with the text it writes to standard output.
POSIX
A family of standards defining interfaces and behavior for Unix-like operating systems, including a shell language.
Readline
The GNU library that provides line editing and history functions for many interactive command-line programs.

Bash syntax is not uniformly portable across shells; scripts intended for broad Unix compatibility should target the required POSIX features explicitly.