Shell
The interactive command interpreter, and a programming language with unusually sharp edges.
A shell is the program that interprets typed commands: it expands words, resolves programs, wires their inputs and outputs together, and reports their exit status. It is simultaneously the most-used interface in software work and a programming language with more surprising behaviour per line than any other in common use.
The behaviours that produce the most wasted time are worth learning explicitly.
Expansion happens before the program runs. A variable in a command line is substituted by the shell, so a program's own configuration file cannot influence an argument the shell already expanded — which is why a command that reads a port from the environment binds the shell's port and not the one in a local configuration file.
Shells differ. Variable names reserved in one are ordinary in another; a script assigning to a name the shell owns dies on its first line with a one-word error.
Quoting is the perennial hazard, and a pattern that becomes empty after expansion may match everything rather than nothing.
A process matcher can match itself. A wait loop that polls for a pattern present in its own command line never exits — wait on an artifact instead.
Exit status is the shell's only universal signal, and it means "the program returned zero", which frequently is not the same as "the thing you wanted happened". See Vacuous Truth.
See also7
Hand-picked in the note itself — the neighbours worth reading next.
Environment Variable
A named value in a process's environment, inherited by its children — the standard configuration channel.
Systems & Tooling14 connections
Glob
Wildcard pattern matching over filenames, similar enough to regular expressions to mislead.
Systems & Tooling10 connections
Process
A running program with its own memory, environment, and identity.
Systems & Tooling10 connections
Dotfiles
A tracked repository of personal configuration, making a machine setup reproducible.
Systems & Tooling6 connections
Port
The numeric endpoint a network service listens on, and a scarce shared resource on a developer machine.
Systems & Tooling8 connections
Character Encoding
The mapping between characters and bytes, and the source of a specific family of invisible bugs.
Systems & Tooling10 connections
Terminal User Interface
An interface rendered as text in a terminal, and the design conventions that make command-line tools humane.
Graphics & Games10 connections
Related2
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from12
Notes elsewhere in the wiki that reach for this one.
- Character EncodingSystems & Tooling
The mapping between characters and bytes, and the source of a specific family of invisible bugs.
- ContainerizationSystems & Tooling
Packaging an application with its dependencies into an isolated, reproducible runtime unit.
- DotfilesSystems & Tooling
A tracked repository of personal configuration, making a machine setup reproducible.
- Environment VariableSystems & Tooling
A named value in a process's environment, inherited by its children — the standard configuration channel.
- Git WorktreeVersion Control & Delivery
An additional working directory attached to one repository, each on its own branch.
- GlobSystems & Tooling
Wildcard pattern matching over filenames, similar enough to regular expressions to mislead.
- PortSystems & Tooling
The numeric endpoint a network service listens on, and a scarce shared resource on a developer machine.
- ProcessSystems & Tooling
A running program with its own memory, environment, and identity.
- Symbolic LinkSystems & Tooling
A file that points at another path, resolved transparently by most operations.
- Terminal User InterfaceGraphics & Games
An interface rendered as text in a terminal, and the design conventions that make command-line tools humane.
- Truncation BiasMethod
Reading a truncated result as if it were the whole result, so every counterexample is invisible.
- XDG Base Directory SpecificationSystems & Tooling
A convention placing configuration, data, cache, and state in defined directories rather than the home directory.