set-option

Bash set -o history

Enables command history collection; interactive shells normally enable it. In scripts use only synthetic entries and explicitly avoid writing personal history. This fixture tests explicit insertion and listing, not terminal history behavior. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): entry present.

Formal Syntax & Structure

bash syntaxbash
set -o history; set +o history

Return Value

exit status

Option-setting command returns zero for a valid request; query status is zero if enabled, one if disabled.

Working Example

Example Snippetbash
unset HISTFILEset -o historyhistory -chistory -s 'fixture entry'history 1 | grep -F 'fixture entry' >/dev/null || exit 1printf 'entry present\n'set +o history
Bash Reference