shopt-option
Bash shopt cdable_vars
When a cd argument does not name a directory, Bash can interpret it as a variable name whose value is the target directory. Use explicit quoted paths in scripts to avoid implicit lookup. This is Bash-specific. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): destination.
Formal Syntax & Structure
bash syntaxbash
shopt -s cdable_vars; shopt -u cdable_vars; shopt -q cdable_varsReturn 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
mkdir destinationwhere=destinationshopt -s cdable_varscd where >/dev/null || exit 1printf '%s\n' "${PWD##*/}"