Search notes:
Bash built-in: set
With set
, values of internal script variables/options can be modified and positional parameters can be set.
Apparently, the current settings can also be queried through the environment variable $-
where set options are indicated by a single letter.
Short and long version
Most options come with two equivalent forms: one is
set -o option-name
, the other is
set -X
, where
X
is a one letter abbreviation for
option-name.
set -o option-name
set -X
Disabling options
Options are, unintuitively, disabled by using a plus (+
) instead of a minus (-
) sign:
set +o option-name
set +X
Setting positional parameters
set
can also be used to set the positional parameters $1
… $n
:
#
# Set positional parameters
#
set one two three
echo \$1=$1
echo \$2=$2
echo \$3=$3
Options
set -e
immediately exits upon encountering an error.
set -h
remember location of executables when they were started.
set -v
(set -o verbose
): echo all commands before executing them.