The Bourne shell (sh) is a shell, or command-line interpreter, for computer operating systems.

The Bourne shell was the default shell for Unix Version 7. Most Unix-like systems continue to have /bin/sh—which will be the Bourne shell, or a symbolic link or hard link to a compatible shell even when other shells are used by most users.

set options

In sh, the set built-in command has the following options:

option Description
An option of a double-dash (“–”) signifies the end of an option list. This is primarily useful when values listed after the options will start with a dash themselves.
-a Mark variables which are modified or created for “export”; environment variables set in this way will be passed on to the environments of any subsequent commands.
-e Exit immediately if a command exits with a non-zero exit status.
-f Disable file name generation (globbing).
-h Locate and remember function commands as functions are defined (function commands are normally located when the function is executed).
-n Read commands but do not execute them.
-t Exit after reading and executing one command.
-u Treat unset variables as an error when substituting.
-v Print shell input lines as they are read.
-x Print commands and their arguments as they are executed.

Using + rather than - causes these flags to be turned off.


set -e
set -x

test 1 -eq 0
echo "never printed"