set-option

Bash set -o keyword

With set -k, assignment-like words following the command name can be placed in the command environment instead of remaining arguments. Prefer ordinary leading environment assignments for clarity; do not enable globally in argument-forwarding code. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): value=sample argc=0; argc=1 arg=BM_DEMO=sample.

Formal Syntax & Structure

bash syntaxbash
set -o keyword; set +o keyword

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 -o keywordbash -c 'printf "value=%s argc=%s\n" "$BM_DEMO" "$#"' demo BM_DEMO=sampleset +o keywordbash -c 'printf "argc=%s arg=%s\n" "$#" "$1"' demo BM_DEMO=sample
Bash Reference