shopt-option

Bash shopt shift_verbose

Requests a diagnostic when shift exceeds the number of positional parameters. The invalid shift still returns nonzero when the option is disabled. Capture diagnostics separately from application output. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): failure=1 remaining=1.

Formal Syntax & Structure

bash syntaxbash
shopt -s shift_verbose; shopt -u shift_verbose; shopt -q shift_verbose

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
set -- oneshopt -s shift_verboseshift 2 2> diagnosticrc=$?[[ $rc != 0 && -s diagnostic && $# == 1 ]] || exit 1printf 'failure=%s remaining=%s\n' "$rc" "$#"
Bash Reference