The set command

The set builtin command is one of the most misunderstood (and overloaded!) commands in Bash. It does several different things depending on how it's called: show names, set shell options, and set shell positional parameters.

First of all, when run on its own with no arguments, set prints a list of all of the variables and any functions for the running shell, in alphabetical order. It includes the full definition of the functions. This is one of several ways to view all of the variables in the shell. We suggest you use declare instead, explained later in this chapter, as it shows more information about properties of the variables.

Secondly, set allows you to specify certain options for how the shell runs, all options starting ...

Get Bash Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.