Jump to content

Bash Shell Scripting/A Few Notes On Terminology

From Wikibooks, open books for an open world

The language of Bash commands is a Turing-complete programming language, meaning that if it is even theoretically possible for a given computation to be performed, then it is theoretically possible to perform it in Bash. Furthermore, from a practical standpoint, it is possible to do some very sophisticated things in Bash, and people often do. Nonetheless, it is usually described as a "shell-scripting language" (or similar) rather than a "programming language", and the programs written in it are usually referred to as "Bash shell scripts" (or similar) rather than "Bash programs". We will follow that convention here, preferring script for a Bash script and program only when referring to external programs that might be invoked from a Bash script.

We will also often use the term utility. This term is somewhat subjective, and usage varies, but it typically describes an external program that requires no human interaction and is intended to work well with other programs. All utilities are programs, so we will use the terms somewhat interchangeably. The extreme opposite of a "utility" is an application; that term is also subjective, with variable usage, but it typically describes an external program that has a relatively complex user interface, possibly a GUI, and is designed to operate relatively standalone. Since applications, by their nature, are not generally called from Bash scripts, we will have less occasion to use that term. Many programs are neither "utilities" nor "applications", and some programs have elements both of utilities and of applications.

Of the various elements of a Bash script, some are typically called commands, while others are typically called statements. We will observe this distinction here, but you need not overly concern yourself with it. The term "statement" in this context refers to programming constructs such as if … then … else … fi or variable assignment, which we will see shortly.

A "command" can refer to the invocation of an external program. These are executable files residing elsewhere on the filesystem: either scripts (collections of human-readable instructions, in the stage production sense of "script") or binaries (non-human-readable machine code). "Command" may also be used as a shorthand to refer to Bash built-ins such as echo or help, as well as aliases and shell functions (which we will see later), since these resemble external programs in their superficial behavior. You can think all these various types of commands as being the "verbs" in the language of the Bash shell.

Commands in the shell environment often require other files as input, or have some non-default behaviors the user may need to activate or tune. For this purpose, external programs as well as built-in commands can accept arguments—in the sense of the algebraic function 3x having an argument x—or options, which you might also see referred to as flags. An example of a command line option or flag would be the cp --help flag that we saw earlier, which instructs the cp command to print some usage information to the screen. The general notion to understand is that these are (often optional) modifiers that alter programs' default behavior, or otherwise supply them with necessary inputs.

If the distinctions between these various terms seems too fine, do not worry; in context, it should always be sufficiently clear what is meant by one term or the other.