set builtin
The builtin that turns shell options on with a minus sign and off with a plus sign, such as set -e and set +x.
In more detail
Options can be combined, as in set -euo pipefail. Run with no arguments it prints every variable, and set -- replaces the positional parameters.
Example
#!/bin/sh
set -eu
go test ./...Related terms
- set -e — The shell option that makes a script exit as soon as a command fails, instead of carrying on.
- set -u — The shell option that makes using an unset variable an error that stops the script, instead of silently expanding to nothing.
- pipefail — The bash option that makes a pipeline fail if any stage fails, instead of reporting only the last stage's status.
- bash -x — Tracing mode, turned on with bash -x or set -x, in which bash prints each command after expansion, just before running it.
- shell — The program that reads the commands you type, runs them and shows the results; sh and bash are common ones.
- exit code — A number a process returns when it finishes: 0 means success, anything else means something went wrong.
- pipeline — An automated sequence of steps, such as build, test, scan and publish, that runs on every change.
Taught in
- Arguments: Dollar One, Dollar At, shift — Bash Scripting & Command Line Automation
- set -e, set -u And pipefail: Promises And Traps — Bash Scripting & Command Line Automation
- Debugging: set -x, bash -n And Reading The Error — Bash Scripting & Command Line Automation
- Style That Prevents Bugs — Bash Scripting & Command Line Automation
- Building Static Binaries — Concurrent Systems Programming with Go
- Containerizing and Testing the Final Build — Concurrent Systems Programming with Go