variable

HISTCONTROL

A colon-delimited selection of history policies. ignorespace omits commands beginning with a space, ignoredups omits an immediately repeated command, and ignoreboth combines them. These are history preferences, not secure secret redaction. This fixture enables history in a noninteractive child and writes only synthetic commands. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): history policy verified.

Formal Syntax & Structure

bash syntaxbash
HISTCONTROL

Return Value

shell variable

Expansion yields the current value; it has no independent command exit status.

Working Example

Example Snippetbash
bash --noprofile --norc -s >/dev/null <<'SCRIPT'set -o historyHISTCONTROL=ignoreboth echo omittedecho keptecho kepthistory -w synthetic.historySCRIPT[[ $(grep -Fxc 'echo kept' synthetic.history) == 1 ]] || exit 1if grep -Fq ' echo omitted' synthetic.history; then exit 1; fiprintf 'history policy verified\n'
Bash Reference