Skip to content
The Bash Insectarium

/static/insetario/en/inseto/traco/

Menu

BSH-024 · Ghost variables

$-

The shell's lit options, one letter per flag.

Each letter in $- is an option turned on: i for interactive, H for history expansion, m for job control, x when set -x tracing is lit.

The classic use lives in startup files: case $- in *i*) separates what only makes sense with a human at the keyboard.

$ echo $-
himBHs
$ bash -c 'echo $-'
hBc
Interactive on one side, script on the other — the flags tell.