variable

OPTERR

When zero, suppresses getopts automatic diagnostics, even without leading colon. Unlike silent mode, a missing value in ordinary mode yields ? and OPTARG is unset.

Formal Syntax & Structure

bash syntaxbash
OPTERR=0

Return Value

integer

When zero, suppresses getopts automatic diagnostics, even without leading colon. Unlike silent mode, a missing value in ordinary mode yields ? and OPTARG is unset.

Working Example

Example Snippetbash
set -- -nOPTERR=0getopts 'n:' optprintf 'opt=%s arg=%s\n' "$opt" "${OPTARG-unset}"
Bash Reference